git commit: TS-2802: SNI support for origin servers - fix WCCP compile errors.
Repository: trafficserver Updated Branches: refs/heads/master 4b2429b60 - 426879358 TS-2802: SNI support for origin servers - fix WCCP compile errors. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/42687935 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/42687935 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/42687935 Branch: refs/heads/master Commit: 426879358105f80785ceeb4ca375581b0c7cf79a Parents: 4b2429b Author: Alan M. Carroll a...@network-geographics.com Authored: Fri Aug 1 09:17:08 2014 -0500 Committer: Alan M. Carroll a...@network-geographics.com Committed: Fri Aug 1 09:17:08 2014 -0500 -- lib/ts/TsBuffer.h | 26 +- lib/tsconfig/TsValue.cc| 6 +++--- lib/tsconfig/TsValue.h | 6 +++--- lib/wccp/WccpLocal.h | 2 +- proxy/http/HttpTransact.cc | 1 - 5 files changed, 16 insertions(+), 25 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/ts/TsBuffer.h -- diff --git a/lib/ts/TsBuffer.h b/lib/ts/TsBuffer.h index 1abc6fe..4ed8ccc 100644 --- a/lib/ts/TsBuffer.h +++ b/lib/ts/TsBuffer.h @@ -52,7 +52,7 @@ namespace ts { char * _ptr; /// Pointer to base of memory chunk. size_t _size; /// Size of memory chunk. -/// Default constructor. +/// Default constructor (empty buffer). Buffer(); /** Construct from pointer and size. @@ -65,13 +65,11 @@ namespace ts { ); /** Construct from two pointers. @note This presumes a half open range, (start, end] - @note Due to ambiguity issues do not invoke this with - @a start == 0. */ Buffer( - char* start, /// First valid character. - char* end /// First invalid character. - ); + char* start, /// First valid character. + char* end /// First invalid character. +); /** Equality. @return @c true if @a that refers to the same memory as @a this, @@ -129,10 +127,6 @@ namespace ts { /** A chunk of read only memory. A convenience class because we pass this kind of pair frequently. - - @note The default construct leaves the object - uninitialized. This is for performance reasons. To construct an - empty @c Buffer use @c Buffer(0). */ struct ConstBuffer { typedef ConstBuffer self; /// Self reference type. @@ -141,12 +135,10 @@ namespace ts { char const * _ptr; /// Pointer to base of memory chunk. size_t _size; /// Size of memory chunk. -/// Default constructor. +/// Default constructor (empty buffer). ConstBuffer(); /** Construct from pointer and size. - @note Due to ambiguity issues do not call this with - two arguments if the first argument is 0. */ ConstBuffer( char const * ptr, /// Pointer to buffer. @@ -158,12 +150,12 @@ namespace ts { @a start == 0. */ ConstBuffer( - char const* start, /// First valid character. - char const* end /// First invalid character. - ); + char const* start, /// First valid character. + char const* end /// First invalid character. +); /// Construct from writable buffer. ConstBuffer( -Buffer const buffer /// Buffer to copy. + Buffer const buffer /// Buffer to copy. ); /** Equality. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/tsconfig/TsValue.cc -- diff --git a/lib/tsconfig/TsValue.cc b/lib/tsconfig/TsValue.cc index d7c1db1..06beaec 100644 --- a/lib/tsconfig/TsValue.cc +++ b/lib/tsconfig/TsValue.cc @@ -37,8 +37,8 @@ // --- namespace ts { namespace config { // --- -Buffer const detail::NULL_BUFFER(0); -ConstBuffer const detail::NULL_CONST_BUFFER(0); +Buffer const detail::NULL_BUFFER; +ConstBuffer const detail::NULL_CONST_BUFFER; detail::ValueItem detail::ValueTableImpl::NULL_ITEM(VoidValue); detail::PseudoBool::Type const detail::PseudoBool::FALSE = 0; detail::PseudoBool::Type const detail::PseudoBool::TRUE = detail::PseudoBool::operator !; @@ -332,7 +332,7 @@ Configuration::getRoot() const { RvConfiguration Configuration::loadFromPath(char const* path) { RvConfiguration zret; -Buffer buffer(0); +Buffer buffer; FILE* in = fopen(path, r); if (in) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/tsconfig/TsValue.h -- diff --git a/lib/tsconfig/TsValue.h
[1/2] TS-2964: Make URL hash run time selectable.
Repository: trafficserver Updated Branches: refs/heads/master 426879358 - 2ac12c4a2 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ac12c4a/lib/ts/INK_MD5.h -- diff --git a/lib/ts/INK_MD5.h b/lib/ts/INK_MD5.h index 37585eb..d5d4e91 100644 --- a/lib/ts/INK_MD5.h +++ b/lib/ts/INK_MD5.h @@ -26,132 +26,19 @@ #include ink_code.h #include ink_defs.h - -struct INK_MD5 -{ - - // This union is needed to fix strict-aliasing warnings. - // It is anonymous so that the 'b' member can remain in - // the top level scope of the struct. This is because - // other code touches that directly. Once that code is - // also fixed we can make this an Alias64 type from - // ink_align.h - union - { -uint64_t b[2]; // Legacy placeholder -uint64_t u64[2]; -uint32_t u32[4]; -uint8_t u8[16]; - }; - - const INK_MD5 operator =(const INK_MD5 md5) - { -u64[0] = md5.u64[0]; -u64[1] = md5.u64[1]; -return *this; - } - uint32_t word(int i) - { -return u32[i]; - } - unsigned char byte(int i) - { -return u8[i]; - } - INK_MD5 loadFromBuffer(char const* md5_buf) { -memcpy((void *) u8, (void *) md5_buf, 16); -return (*this); - } - INK_MD5 storeToBuffer(char const* md5_buf) { -memcpy((void *) md5_buf, (void *) u8, 16); -return (*this); - } - INK_MD5 operator =(char const* md5) { -return (loadFromBuffer(md5)); - } - INK_MD5 operator =(unsigned char const* md5) { -return (loadFromBuffer((char *) md5)); - } - - char *toStr(char *md5_str) - { -return (char *) memcpy((void *) md5_str, (void *) u8, 16); - } - void encodeBuffer(unsigned char const* buffer, int len) - { -ink_code_md5(buffer, len, u8); - } - void encodeBuffer(const char *buffer, int len) - { -encodeBuffer(reinterpret_castunsigned char const*(buffer), len); - } - char *str() - { -return ((char *) u8); - } - char *toHexStr(char hex_md5[33]) - { -return (ink_code_md5_stringify_fast(hex_md5, str())); - } - void set(INK_MD5 md5) - { -loadFromBuffer((char *) md5.u8); - } - void set(INK_MD5 * md5) - { -loadFromBuffer((char *) md5-u8); - } - void set(char *p) - { -loadFromBuffer(p); - } - void set(uint64_t a1, uint64_t a2) - { -u64[0] = a1; -u64[1] = a2; - } - char *string(char buf[33]) - { -char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; -int i, j; - -for (i = 0, j = 0; i 16; i += 1, j += 2) { - buf[j + 0] = hex_digits[u8[i] 4]; - buf[j + 1] = hex_digits[u8[i] 0xF]; -} -buf[32] = '\0'; -return buf; - } - - uint64_t fold() const - { -return (u64[0] ^ u64[1]); - } - - uint64_t operator[] (int i) const - { -return u64[i]; - } - bool operator==(INK_MD5 const md5) const - { -return u64[0] == md5.u64[0] u64[1] == md5.u64[1]; - } - bool operator != (INK_MD5 const that) const - { -return !(*this == that); - } - - INK_MD5() { -u64[0] = 0; -u64[1] = 0; - } - INK_MD5(uint64_t a1, uint64_t a2) { -u64[0] = a1; -u64[1] = a2; - } - - /// Static default constructed instance. - static INK_MD5 const ZERO; +#include CryptoHash.h + +class MD5Context : public CryptoContext { +protected: + MD5_CTX _ctx; +public: + MD5Context(); + /// Update the hash with @a data of @a length bytes. + virtual bool update(void const* data, int length); + /// Finalize and extract the @a hash. + virtual bool finalize(CryptoHash hash); }; +typedef CryptoHash INK_MD5; + #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ac12c4a/lib/ts/MMH.cc -- diff --git a/lib/ts/MMH.cc b/lib/ts/MMH.cc new file mode 100644 index 000..66d5c48 --- /dev/null +++ b/lib/ts/MMH.cc @@ -0,0 +1,588 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an AS IS BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include stdlib.h +#include string.h +#include ink_assert.h +#include ink_platform.h +#include MMH.h + +#define MMH_X_SIZE 512 + +/* BUG: INKqa11504: need it be to 64 bits...otherwise it overflows */ +static uint64_t
[2/2] git commit: TS-2964: Make URL hash run time selectable.
TS-2964: Make URL hash run time selectable. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2ac12c4a Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2ac12c4a Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2ac12c4a Branch: refs/heads/master Commit: 2ac12c4a2770600743d12964f4b998ba38b05116 Parents: 4268793 Author: Alan M. Carroll a...@network-geographics.com Authored: Mon Jul 28 10:39:21 2014 -0500 Committer: Alan M. Carroll a...@network-geographics.com Committed: Fri Aug 1 09:24:33 2014 -0500 -- iocore/cache/Cache.cc | 72 ++--- iocore/cache/CacheDir.cc | 112 +++ iocore/cache/CacheHosting.cc | 4 +- iocore/cache/CacheHttp.cc | 2 +- iocore/cache/CachePages.cc | 8 +- iocore/cache/CacheRead.cc | 60 ++-- iocore/cache/CacheTest.cc | 4 +- iocore/cache/CacheVol.cc | 2 +- iocore/cache/CacheWrite.cc | 58 ++-- iocore/cache/P_CacheDir.h | 4 +- iocore/cache/P_CacheHosting.h | 4 +- iocore/cache/P_CacheInternal.h | 12 +- iocore/cache/P_CacheVol.h | 50 +-- iocore/cache/RamCacheCLFUS.cc | 46 +-- iocore/cache/RamCacheLRU.cc| 22 +- iocore/hostdb/HostDB.cc| 3 +- lib/ts/CryptoHash.h| 124 lib/ts/INK_MD5.h | 139 + lib/ts/MMH.cc | 588 lib/ts/MMH.h | 119 lib/ts/Makefile.am | 3 + lib/ts/ink_code.cc | 37 ++- lib/ts/ink_code.h | 3 +- lib/ts/libts.h | 1 + proxy/InkAPI.cc| 11 +- proxy/Prefetch.cc | 8 +- proxy/Update.cc| 3 +- proxy/hdrs/URL.cc | 82 ++--- proxy/hdrs/URL.h | 41 ++- proxy/http/HttpServerSession.h | 2 +- proxy/logging/LogFormat.cc | 12 +- proxy/logging/LogObject.cc | 7 +- 32 files changed, 1208 insertions(+), 435 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2ac12c4a/iocore/cache/Cache.cc -- diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc index 03a3650..7d4a8f1 100644 --- a/iocore/cache/Cache.cc +++ b/iocore/cache/Cache.cc @@ -116,7 +116,7 @@ ClassAllocatorEvacuationBlock evacuationBlockAllocator(evacuationBlock); ClassAllocatorCacheRemoveCont cacheRemoveContAllocator(cacheRemoveCont); ClassAllocatorEvacuationKey evacuationKeyAllocator(evacuationKey); int CacheVC::size_to_init = -1; -CacheKey zero_key(0, 0); +CacheKey zero_key; #if TS_USE_INTERIM_CACHE == 1 ClassAllocatorMigrateToInterimCache migrateToInterimCacheAllocator(migrateToInterimCache); #endif @@ -1114,7 +1114,7 @@ int Vol::db_check(bool /* fix ATS_UNUSED */ ) { char tt[256]; - printf(Data for [%s]\n, hash_id); + printf(Data for [%s]\n, hash_text); printf(Length: % PRIu64 \n, (uint64_t)len); printf(Write Position: % PRIu64 \n, (uint64_t) (header-write_pos - skip)); printf(Phase: %d\n, (int)!!header-phase); @@ -1212,7 +1212,7 @@ vol_dir_clear(Vol *d) vol_clear_init(d); if (pwrite(d-fd, d-raw_dir, dir_len, d-skip) 0) { -Warning(unable to clear cache directory '%s', d-hash_id); +Warning(unable to clear cache directory '%s', d-hash_text); return -1; } return 0; @@ -1242,13 +1242,13 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear) { dir_skip = ROUND_TO_STORE_BLOCK((dir_skip START_POS ? START_POS : dir_skip)); path = ats_strdup(s); - const size_t hash_id_size = strlen(s) + 32; - hash_id = (char *)ats_malloc(hash_id_size); - ink_strlcpy(hash_id, s, hash_id_size); + const size_t hash_text_size = strlen(s) + 32; + hash_text = (char *)ats_malloc(hash_text_size); + ink_strlcpy(hash_text, s, hash_text_size); const size_t s_size = strlen(s); - snprintf(hash_id + s_size, (hash_id_size - s_size), % PRIu64 :% PRIu64 , + snprintf(hash_text + s_size, (hash_text_size - s_size), % PRIu64 :% PRIu64 , (uint64_t)dir_skip, (uint64_t)blocks); - hash_id_md5.encodeBuffer(hash_id, strlen(hash_id)); + MD5Context().hash_immediate(hash_id, hash_text, strlen(hash_text)); len = blocks * STORE_BLOCK_SIZE; ink_assert(len = MAX_VOL_SIZE); skip = dir_skip; @@ -1286,7 +1286,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear) #endif if (clear) { -Note(clearing cache directory '%s', hash_id); +Note(clearing cache directory '%s', hash_text); return clear_dir(); } @@ -1296,7 +1296,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool clear) // try A off_t as = skip; if (is_debug_tag_set(cache_init)) -Note(reading directory
Re: git commit: TS-2802: SNI support for origin servers - fix WCCP compile errors.
Thanks Alan! On Aug 1, 2014, at 7:20 AM, a...@apache.org wrote: Repository: trafficserver Updated Branches: refs/heads/master 4b2429b60 - 426879358 TS-2802: SNI support for origin servers - fix WCCP compile errors. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/42687935 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/42687935 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/42687935 Branch: refs/heads/master Commit: 426879358105f80785ceeb4ca375581b0c7cf79a Parents: 4b2429b Author: Alan M. Carroll a...@network-geographics.com Authored: Fri Aug 1 09:17:08 2014 -0500 Committer: Alan M. Carroll a...@network-geographics.com Committed: Fri Aug 1 09:17:08 2014 -0500 -- lib/ts/TsBuffer.h | 26 +- lib/tsconfig/TsValue.cc| 6 +++--- lib/tsconfig/TsValue.h | 6 +++--- lib/wccp/WccpLocal.h | 2 +- proxy/http/HttpTransact.cc | 1 - 5 files changed, 16 insertions(+), 25 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/ts/TsBuffer.h -- diff --git a/lib/ts/TsBuffer.h b/lib/ts/TsBuffer.h index 1abc6fe..4ed8ccc 100644 --- a/lib/ts/TsBuffer.h +++ b/lib/ts/TsBuffer.h @@ -52,7 +52,7 @@ namespace ts { char * _ptr; /// Pointer to base of memory chunk. size_t _size; /// Size of memory chunk. -/// Default constructor. +/// Default constructor (empty buffer). Buffer(); /** Construct from pointer and size. @@ -65,13 +65,11 @@ namespace ts { ); /** Construct from two pointers. @note This presumes a half open range, (start, end] - @note Due to ambiguity issues do not invoke this with - @a start == 0. */ Buffer( -char* start, /// First valid character. -char* end /// First invalid character. -); + char* start, /// First valid character. + char* end /// First invalid character. +); /** Equality. @return @c true if @a that refers to the same memory as @a this, @@ -129,10 +127,6 @@ namespace ts { /** A chunk of read only memory. A convenience class because we pass this kind of pair frequently. - - @note The default construct leaves the object - uninitialized. This is for performance reasons. To construct an - empty @c Buffer use @c Buffer(0). */ struct ConstBuffer { typedef ConstBuffer self; /// Self reference type. @@ -141,12 +135,10 @@ namespace ts { char const * _ptr; /// Pointer to base of memory chunk. size_t _size; /// Size of memory chunk. -/// Default constructor. +/// Default constructor (empty buffer). ConstBuffer(); /** Construct from pointer and size. - @note Due to ambiguity issues do not call this with - two arguments if the first argument is 0. */ ConstBuffer( char const * ptr, /// Pointer to buffer. @@ -158,12 +150,12 @@ namespace ts { @a start == 0. */ ConstBuffer( -char const* start, /// First valid character. -char const* end /// First invalid character. -); + char const* start, /// First valid character. + char const* end /// First invalid character. +); /// Construct from writable buffer. ConstBuffer( -Buffer const buffer /// Buffer to copy. + Buffer const buffer /// Buffer to copy. ); /** Equality. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/tsconfig/TsValue.cc -- diff --git a/lib/tsconfig/TsValue.cc b/lib/tsconfig/TsValue.cc index d7c1db1..06beaec 100644 --- a/lib/tsconfig/TsValue.cc +++ b/lib/tsconfig/TsValue.cc @@ -37,8 +37,8 @@ // --- namespace ts { namespace config { // --- -Buffer const detail::NULL_BUFFER(0); -ConstBuffer const detail::NULL_CONST_BUFFER(0); +Buffer const detail::NULL_BUFFER; +ConstBuffer const detail::NULL_CONST_BUFFER; detail::ValueItem detail::ValueTableImpl::NULL_ITEM(VoidValue); detail::PseudoBool::Type const detail::PseudoBool::FALSE = 0; detail::PseudoBool::Type const detail::PseudoBool::TRUE = detail::PseudoBool::operator !; @@ -332,7 +332,7 @@ Configuration::getRoot() const { RvConfiguration Configuration::loadFromPath(char const* path) { RvConfiguration zret; -Buffer buffer(0); +Buffer buffer; FILE* in = fopen(path, r); if (in) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42687935/lib/tsconfig/TsValue.h
git commit: TS-2964: Fix searchreplace error in CachePagesInternal.cc
Repository: trafficserver Updated Branches: refs/heads/master 2ac12c4a2 - c0e5dc6f1 TS-2964: Fix searchreplace error in CachePagesInternal.cc Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c0e5dc6f Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c0e5dc6f Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c0e5dc6f Branch: refs/heads/master Commit: c0e5dc6f17a814ae9126d0106995983b3351873a Parents: 2ac12c4 Author: Alan M. Carroll a...@network-geographics.com Authored: Fri Aug 1 11:15:57 2014 -0500 Committer: Alan M. Carroll a...@network-geographics.com Committed: Fri Aug 1 11:15:57 2014 -0500 -- iocore/cache/CachePagesInternal.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c0e5dc6f/iocore/cache/CachePagesInternal.cc -- diff --git a/iocore/cache/CachePagesInternal.cc b/iocore/cache/CachePagesInternal.cc index 316b499..6221191 100644 --- a/iocore/cache/CachePagesInternal.cc +++ b/iocore/cache/CachePagesInternal.cc @@ -283,7 +283,7 @@ ShowCacheInternal::showVolVolumes(int event, Event * e) td%u/td // sync serial td%u/td // write serial /tr\n, - p-hash_id, + p-hash_text, (uint64_t)((p-len - (p-start - p-skip)) / CACHE_BLOCK_SIZE), (uint64_t)(p-buckets * DIR_DEPTH * p-segments), (uint64_t)((p-header-write_pos - p-start) / CACHE_BLOCK_SIZE),
git commit: TS-2980: Fix RAT report exceptions.
Repository: trafficserver Updated Branches: refs/heads/4.2.x de2f11742 - 92d152f61 TS-2980: Fix RAT report exceptions. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/92d152f6 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/92d152f6 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/92d152f6 Branch: refs/heads/4.2.x Commit: 92d152f61a5fb82bb471f3904dc624decc6499ce Parents: de2f117 Author: Phil Sorber sor...@apache.org Authored: Fri Aug 1 10:16:14 2014 -0600 Committer: Phil Sorber sor...@apache.org Committed: Fri Aug 1 10:16:14 2014 -0600 -- ci/jenkins/records.config.pristine | 1 - ci/rat-excludes.txt| 129 ci/rat-regex.txt | 5 ++ 3 files changed, 5 insertions(+), 130 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/92d152f6/ci/jenkins/records.config.pristine -- diff --git a/ci/jenkins/records.config.pristine b/ci/jenkins/records.config.pristine deleted file mode 100644 index 0b17bae..000 --- a/ci/jenkins/records.config.pristine +++ /dev/null @@ -1 +0,0 @@ -CONFIG proxy.config.url_remap.pristine_host_hdr INT 0 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/92d152f6/ci/rat-excludes.txt -- diff --git a/ci/rat-excludes.txt b/ci/rat-excludes.txt deleted file mode 100644 index 2e59588..000 --- a/ci/rat-excludes.txt +++ /dev/null @@ -1,129 +0,0 @@ -ci/ -proxy/config/ -**/*.a -**/*.so -**/*.o -**/*.Po -**/*.in -**/*.Plo -**/*.la -**/*.lai -**/*.lo -**/.dirstamp -**/Makefile -**/TODO -.vimrc -.clang-format -.gitignore -**/.gitignore -.git/ -.indent.pro -aclocal.m4 -CHANGES -CRUFT.txt -autom4te.cache/ -build/ -LAYOUT -configure -tags -libtool -config.log -config.status -config.nice -configure -REVIEWERS -proxy/README-stats.otl -proxy/http/README.via -proxy/ClassH.txt -proxy/DebugStreamLevels.txt -proxy/trafficserver-release -proxy/cache_test.config -proxy/congest/FeatureSpec.txt -proxy/http/stats.memo -proxy/issues.txt -proxy/test_xml_parser -proxy/tests/logstats.json -proxy/tests/logstats.summary -mgmt/cli/cli_detailed_command_list.txt -mgmt/cli/cli_feature_spec.txt -example/README.internal -example/blacklist-1/blacklist.txt -example/thread-pool/TESTPLAN.txt -example/thread-pool/test/SynTest/ -example/thread-pool/test/SDKTest/SDKtest_server.config -example/app-template/records.config -doc/docbuild/ -doc/dot/ -doc/Doxyfile -doc/Doxyfile.in -doc/static/images/press/trafficserver.svg -lib/tsconfig/test-tsconfig -lib/tsconfig/TsConfigGrammar.hpp -lib/ts/ParseRulesCType -lib/ts/ParseRulesCTypeToLower -lib/ts/ParseRulesCTypeToUpper -lib/ts/test_Map -lib/ts/test_Vec -lib/ts/test_arena -lib/ts/test_atomic -lib/ts/test_freelist -lib/ts/fastlz.h -lib/ts/fastlz.c -lib/ts/stamp-h1 -iocore/fastio/inkfio/inkfio.conf -iocore/aio/sample.cfg -iocore/cache/Notes -iocore/cache/cache_test.config -iocore/fastio/tools/advbmark/runme -iocore/net/test_certlookup -lib/records/test_records.config -mgmt/stats/spec -proxy/mime.types -proxy/msgs/TSMessages.mc -proxy/msgs/TSMsgs.rc -test/SDKtest/synth_server/SDKtest_server.config -test/deft/defs/climatelab.def -test/deft/defs/localhost.def -test/plugin/INKHttpHooksTrans/altSelect.notes -mgmt/cli/hashtable.cc -lib/ts/ink_res_init.cc -lib/ts/ink_res_mkquery.cc -lib/ts/ink_rand.h -lib/ts/ink_rand.cc -lib/tsconfig/BisonHeaderToC++.sed -README-EC2 -REVIEWERS -lib/perl/MANIFEST -lib/perl/Makefile-pl -lib/perl/blib/ -lib/perl/pm_to_blib -ats-install/ -cop/traffic_cop -mgmt/api/remote/traffic_api_cli_remote -mgmt/cli/traffic_line -mgmt/cli/traffic_shell -mgmt/traffic_manager -proxy/traffic_server -proxy/traffic_logcat -proxy/traffic_logstats -proxy/traffic_sac -lib/tsconfig/test-1.tsconfig -rc/solaris.txt -rc/trafficserver.service -tools/http_load/ -tools/tstop/tstop -tools/jtest/jtest -plugins/experimental/stale_while_revalidate/stale_while_revalidate.conf -plugins/experimental/tcp_info/tcp_info.config -plugins/experimental/esi/docnode_test -plugins/experimental/esi/parser_test -plugins/experimental/esi/processor_test -plugins/experimental/esi/utils_test -plugins/experimental/esi/vars_test -plugins/experimental/esi/README.combo -iocore/aio/diags.log -iocore/aio/test_AIO -iocore/aio/test_AIO.sample -iocore/eventsystem/diags.log -iocore/eventsystem/test_Buffer -iocore/eventsystem/test_Event http://git-wip-us.apache.org/repos/asf/trafficserver/blob/92d152f6/ci/rat-regex.txt -- diff --git a/ci/rat-regex.txt b/ci/rat-regex.txt index ec0ccc5..cf0fd96 100644 --- a/ci/rat-regex.txt +++ b/ci/rat-regex.txt @@ -3,6 +3,10 @@
git commit: TS-2367: Add OCSP (Online Certificate Status Protocol) Stapling Support
Repository: trafficserver Updated Branches: refs/heads/master c0e5dc6f1 - 562179c50 TS-2367: Add OCSP (Online Certificate Status Protocol) Stapling Support Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/562179c5 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/562179c5 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/562179c5 Branch: refs/heads/master Commit: 562179c50eae3422ac9b4fe50a1b41ea09712ad1 Parents: c0e5dc6 Author: Feifei Cai ff...@yahoo-inc.com Authored: Fri Aug 1 10:57:45 2014 -0700 Committer: Bryan Call bc...@apache.org Committed: Fri Aug 1 10:57:45 2014 -0700 -- iocore/net/Makefile.am| 2 ++ iocore/net/P_SSLConfig.h | 5 + iocore/net/SSLConfig.cc | 10 ++ iocore/net/SSLNetProcessor.cc | 33 ++--- iocore/net/SSLUtils.cc| 21 + mgmt/RecordsConfig.cc | 17 + 6 files changed, 85 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/562179c5/iocore/net/Makefile.am -- diff --git a/iocore/net/Makefile.am b/iocore/net/Makefile.am index 9ce103f..cfbdb4b 100644 --- a/iocore/net/Makefile.am +++ b/iocore/net/Makefile.am @@ -72,6 +72,7 @@ libinknet_a_SOURCES = \ P_SSLNextProtocolAccept.h \ P_SSLNextProtocolSet.h \ P_SSLUtils.h \ + P_OCSPStapling.h \ P_Socks.h \ P_UDPConnection.h \ P_UDPIOEvent.h \ @@ -93,6 +94,7 @@ libinknet_a_SOURCES = \ SSLNextProtocolAccept.cc \ SSLNextProtocolSet.cc \ SSLUtils.cc \ + OCSPStapling.cc \ Socks.cc \ UDPIOEvent.cc \ UnixConnection.cc \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/562179c5/iocore/net/P_SSLConfig.h -- diff --git a/iocore/net/P_SSLConfig.h b/iocore/net/P_SSLConfig.h index 31a6242..aa4926f 100644 --- a/iocore/net/P_SSLConfig.h +++ b/iocore/net/P_SSLConfig.h @@ -83,6 +83,11 @@ struct SSLConfigParams : public ConfigInfo static int ssl_maxrecord; static bool ssl_allow_client_renegotiation; + static bool ssl_ocsp_enabled; + static int ssl_ocsp_cache_timeout; + static int ssl_ocsp_request_timeout; + static int ssl_ocsp_update_period; + static init_ssl_ctx_func init_ssl_ctx_cb; void initialize(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/562179c5/iocore/net/SSLConfig.cc -- diff --git a/iocore/net/SSLConfig.cc b/iocore/net/SSLConfig.cc index 25c2875..402664a 100644 --- a/iocore/net/SSLConfig.cc +++ b/iocore/net/SSLConfig.cc @@ -43,6 +43,10 @@ int SSLConfig::configid = 0; int SSLCertificateConfig::configid = 0; int SSLConfigParams::ssl_maxrecord = 0; bool SSLConfigParams::ssl_allow_client_renegotiation = false; +bool SSLConfigParams::ssl_ocsp_enabled = false; +int SSLConfigParams::ssl_ocsp_cache_timeout = 3600; +int SSLConfigParams::ssl_ocsp_request_timeout = 10; +int SSLConfigParams::ssl_ocsp_update_period = 60; init_ssl_ctx_func SSLConfigParams::init_ssl_ctx_cb = NULL; static ConfigUpdateHandlerSSLCertificateConfig * sslCertUpdate; @@ -249,6 +253,12 @@ SSLConfigParams::initialize() // SSL record size REC_EstablishStaticConfigInt32(ssl_maxrecord, proxy.config.ssl.max_record_size); + // SSL OCSP Stapling configurations + REC_ReadConfigInt32(ssl_ocsp_enabled, proxy.config.ssl.ocsp.enabled); + REC_EstablishStaticConfigInt32(ssl_ocsp_cache_timeout, proxy.config.ssl.ocsp.cache_timeout); + REC_EstablishStaticConfigInt32(ssl_ocsp_request_timeout, proxy.config.ssl.ocsp.request_timeout); + REC_EstablishStaticConfigInt32(ssl_ocsp_update_period, proxy.config.ssl.ocsp.update_period); + // Client part client_verify_depth = 7; REC_ReadConfigInt32(clientVerify, proxy.config.ssl.client.verify.server); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/562179c5/iocore/net/SSLNetProcessor.cc -- diff --git a/iocore/net/SSLNetProcessor.cc b/iocore/net/SSLNetProcessor.cc index 47bdb59..5c2d8cc 100644 --- a/iocore/net/SSLNetProcessor.cc +++ b/iocore/net/SSLNetProcessor.cc @@ -25,6 +25,7 @@ #include I_Layout.h #include I_RecHttp.h #include P_SSLUtils.h +#include P_OCSPStapling.h // // Global Data @@ -34,6 +35,21 @@ SSLNetProcessor ssl_NetProcessor; NetProcessor sslNetProcessor = ssl_NetProcessor; EventType SSLNetProcessor::ET_SSL; +struct OCSPContinuation:public Continuation +{ + int mainEvent(int /* event ATS_UNUSED */, Event *e) + { +ocsp_update(); + +return EVENT_CONT; + } + +
git commit: TS-2367: Add OCSP (Online Certificate Status Protocol) Stapling Support
Repository: trafficserver Updated Branches: refs/heads/master 562179c50 - 2621e676c TS-2367: Add OCSP (Online Certificate Status Protocol) Stapling Support Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2621e676 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2621e676 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2621e676 Branch: refs/heads/master Commit: 2621e676c2b3880c5f3d822bf6e0e5cf30c021fc Parents: 562179c Author: Feifei Cai ff...@yahoo-inc.com Authored: Fri Aug 1 11:02:43 2014 -0700 Committer: Bryan Call bc...@apache.org Committed: Fri Aug 1 11:02:43 2014 -0700 -- iocore/net/OCSPStapling.cc | 412 +++ iocore/net/P_OCSPStapling.h | 35 2 files changed, 447 insertions(+) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2621e676/iocore/net/OCSPStapling.cc -- diff --git a/iocore/net/OCSPStapling.cc b/iocore/net/OCSPStapling.cc new file mode 100644 index 000..ca27b00 --- /dev/null +++ b/iocore/net/OCSPStapling.cc @@ -0,0 +1,412 @@ +/** @file + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an AS IS BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include openssl/ocsp.h +#include P_OCSPStapling.h +#include P_Net.h +#include P_SSLConfig.h + +#ifdef HAVE_OPENSSL_OCSP_STAPLING + +// Maxiumum OCSP stapling response size. +// This should be the response for a single certificate and will typically include the responder certificate chain, +// so 10K should be more than enough. +#define MAX_STAPLING_DER 10240 + +// Cached info stored in SSL_CTX ex_info +struct certinfo +{ + unsigned char idx[20]; // Index in session cache SHA1 hash of certificate + OCSP_CERTID *cid; // Certificate ID for OCSP requests or NULL if ID cannot be determined + char *uri; // Responder details + ink_mutex stapling_mutex; + unsigned char resp_der[MAX_STAPLING_DER]; + unsigned int resp_derlen; + bool is_expire; + time_t expire_time; +}; + +void certinfo_free(void * /*parent*/, void *ptr, CRYPTO_EX_DATA * /*ad*/, +int /*idx*/, long /*argl*/, void * /*argp*/) +{ + certinfo *cinf = (certinfo *)ptr; + + if (!cinf) +return; + if (cinf-uri) +OPENSSL_free(cinf-uri); + ink_mutex_destroy(cinf-stapling_mutex); + OPENSSL_free(cinf); +} + +static int ssl_stapling_index = -1; + +void ssl_stapling_ex_init(void) +{ + if (ssl_stapling_index != -1) +return; + ssl_stapling_index = SSL_CTX_get_ex_new_index(0, 0, 0, 0, certinfo_free); +} + +static X509 * +stapling_get_issuer(SSL_CTX *ssl_ctx, X509 *x) +{ + X509 *issuer = NULL; + int i; + X509_STORE *st = SSL_CTX_get_cert_store(ssl_ctx); + X509_STORE_CTX inctx; + STACK_OF(X509) *extra_certs = NULL; + +#ifdef SSL_CTX_get_extra_chain_certs + SSL_CTX_get_extra_chain_certs(ssl_ctx, extra_certs); +#else + extra_certs = ssl_ctx-extra_certs; +#endif + + if (sk_X509_num(extra_certs) == 0) +return NULL; + + for (i = 0; i sk_X509_num(extra_certs); i++) { +issuer = sk_X509_value(extra_certs, i); +if (X509_check_issued(issuer, x) == X509_V_OK) { + CRYPTO_add(issuer-references, 1, CRYPTO_LOCK_X509); + return issuer; +} + } + + if (!X509_STORE_CTX_init(inctx, st, NULL, NULL)) +return NULL; + if (X509_STORE_CTX_get1_issuer(issuer, inctx, x) = 0) +issuer = NULL; + X509_STORE_CTX_cleanup(inctx); + + return issuer; +} + +bool +ssl_stapling_init_cert(SSL_CTX *ctx, const char *certfile) +{ + certinfo *cinf; + X509 *cert = NULL; + X509 *issuer = NULL; + STACK_OF(OPENSSL_STRING) *aia = NULL; + BIO *bio = BIO_new_file(certfile, r); + + cert = PEM_read_bio_X509_AUX(bio, NULL, NULL, NULL); + if (!cert) { +Debug(ssl, can not read cert from certfile %s!, certfile); +return false; + } + + cinf = (certinfo *)SSL_CTX_get_ex_data(ctx, ssl_stapling_index); + if (cinf) { +Debug(ssl, certificate already initialized!); +return false; + } + + cinf = (certinfo *)OPENSSL_malloc(sizeof(certinfo)); + if (!cinf) { +Debug(ssl, error
git commit: TS-2957 TS-1475 Remove unused initialization, make clang-analyzer happy
Repository: trafficserver Updated Branches: refs/heads/master 2621e676c - bd4fa4775 TS-2957 TS-1475 Remove unused initialization, make clang-analyzer happy Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/bd4fa477 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/bd4fa477 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/bd4fa477 Branch: refs/heads/master Commit: bd4fa47753983f5bef2f15ac7a0765881cc871b2 Parents: 2621e67 Author: Leif Hedstrom zw...@apache.org Authored: Fri Aug 1 12:03:52 2014 -0600 Committer: Leif Hedstrom zw...@apache.org Committed: Fri Aug 1 12:03:55 2014 -0600 -- plugins/experimental/sslheaders/util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bd4fa477/plugins/experimental/sslheaders/util.cc -- diff --git a/plugins/experimental/sslheaders/util.cc b/plugins/experimental/sslheaders/util.cc index c25b512..049d7b6 100644 --- a/plugins/experimental/sslheaders/util.cc +++ b/plugins/experimental/sslheaders/util.cc @@ -39,7 +39,7 @@ extern char assert_fields_are_populated[((sizeof(fields)/sizeof(fields[0])) - NU bool SslHdrParseExpansion(const char * spec, SslHdrExpansion exp) { - const char * sep = strchr(spec, '='); + const char * sep; const char * selector; // First, split on '=' to separate the header name from the SSL expansion.
git commit: TS-2367: Couple fixes to make builds happy
Repository: trafficserver Updated Branches: refs/heads/master bd4fa4775 - 17ae8069a TS-2367: Couple fixes to make builds happy Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/17ae8069 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/17ae8069 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/17ae8069 Branch: refs/heads/master Commit: 17ae8069acb908fece508e323c791e52a8c91a3c Parents: bd4fa47 Author: Bryan Call bc...@apache.org Authored: Fri Aug 1 11:33:07 2014 -0700 Committer: Bryan Call bc...@apache.org Committed: Fri Aug 1 11:33:07 2014 -0700 -- iocore/net/P_OCSPStapling.h | 2 ++ iocore/net/SSLNetProcessor.cc | 1 + 2 files changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17ae8069/iocore/net/P_OCSPStapling.h -- diff --git a/iocore/net/P_OCSPStapling.h b/iocore/net/P_OCSPStapling.h index d036651..5d414e8 100644 --- a/iocore/net/P_OCSPStapling.h +++ b/iocore/net/P_OCSPStapling.h @@ -24,6 +24,7 @@ #include openssl/ssl.h +#ifdef sk_OPENSSL_STRING_pop #ifdef SSL_CTX_set_tlsext_status_cb #define HAVE_OPENSSL_OCSP_STAPLING 1 void ssl_stapling_ex_init(); @@ -31,5 +32,6 @@ void ocsp_update(); int ssl_callback_ocsp_stapling(SSL *); #endif /* SSL_CTX_set_tlsext_status_cb */ +#endif /* sk_OPENSSL_STRING_pop */ #endif /* __P_OCSPSTAPLING_H__ */ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/17ae8069/iocore/net/SSLNetProcessor.cc -- diff --git a/iocore/net/SSLNetProcessor.cc b/iocore/net/SSLNetProcessor.cc index 5c2d8cc..b8e72fd 100644 --- a/iocore/net/SSLNetProcessor.cc +++ b/iocore/net/SSLNetProcessor.cc @@ -39,6 +39,7 @@ struct OCSPContinuation:public Continuation { int mainEvent(int /* event ATS_UNUSED */, Event *e) { +(void)e; ocsp_update(); return EVENT_CONT;
git commit: TS-2367: A better way to declare an argument as unused
Repository: trafficserver Updated Branches: refs/heads/master 17ae8069a - 8bed36eed TS-2367: A better way to declare an argument as unused Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8bed36ee Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8bed36ee Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8bed36ee Branch: refs/heads/master Commit: 8bed36eed7819912723a583d2ceeef7cd19ea4b7 Parents: 17ae806 Author: Bryan Call bc...@apache.org Authored: Fri Aug 1 11:47:09 2014 -0700 Committer: Bryan Call bc...@apache.org Committed: Fri Aug 1 11:47:09 2014 -0700 -- iocore/net/SSLNetProcessor.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8bed36ee/iocore/net/SSLNetProcessor.cc -- diff --git a/iocore/net/SSLNetProcessor.cc b/iocore/net/SSLNetProcessor.cc index b8e72fd..c6d1a02 100644 --- a/iocore/net/SSLNetProcessor.cc +++ b/iocore/net/SSLNetProcessor.cc @@ -37,9 +37,8 @@ EventType SSLNetProcessor::ET_SSL; struct OCSPContinuation:public Continuation { - int mainEvent(int /* event ATS_UNUSED */, Event *e) + int mainEvent(int /* event ATS_UNUSED */, Event* /* e ATS_UNUSED */) { -(void)e; ocsp_update(); return EVENT_CONT;
git commit: TS-2964: Make hash runtime selectable - fix gcc issues.
Repository: trafficserver Updated Branches: refs/heads/master 8bed36eed - de6bac77d TS-2964: Make hash runtime selectable - fix gcc issues. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/de6bac77 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/de6bac77 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/de6bac77 Branch: refs/heads/master Commit: de6bac77d013c0d7774d7e9641f519d56d0cc8d4 Parents: 8bed36e Author: Alan M. Carroll a...@network-geographics.com Authored: Fri Aug 1 14:20:02 2014 -0500 Committer: Alan M. Carroll a...@network-geographics.com Committed: Fri Aug 1 14:20:02 2014 -0500 -- proxy/hdrs/URL.cc | 4 ++-- proxy/hdrs/URL.h | 17 + 2 files changed, 11 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de6bac77/proxy/hdrs/URL.cc -- diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc index 7a34106..9a7bfec 100644 --- a/proxy/hdrs/URL.cc +++ b/proxy/hdrs/URL.cc @@ -103,10 +103,10 @@ URLHashContext::URLHashContext() { switch (Setting) { case UNSPECIFIED: case MD5: -_ctx = new(_obj) MD5Context; +new(_obj) MD5Context; break; case MMH: -_ctx = new(_obj) MMHContext; +new(_obj) MMHContext; break; default: ink_assert(Invalid global URL hash context); }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/de6bac77/proxy/hdrs/URL.h -- diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h index 5bed604..c26c1b4 100644 --- a/proxy/hdrs/URL.h +++ b/proxy/hdrs/URL.h @@ -89,11 +89,9 @@ struct URLImpl:public HdrHeapObjImpl /// Crypto Hash context for URLs. /// @internal This just forwards on to another specific context but avoids -/// putting that switch logic in multiple places. +/// putting that switch logic in multiple places. The working context is put +/// in to class local storage (@a _obj) via placement @a new. class URLHashContext : public CryptoContext { -protected: - CryptoContext* _ctx; /// Generic pointer to use for operations. - uint64_t _obj[32]; /// Raw storage for instantiated context. public: URLHashContext(); /// Update the hash with @a data of @a length bytes. @@ -104,16 +102,19 @@ public: enum HashType { UNSPECIFIED, MD5, MMH }; /// What type of hash we really are. static HashType Setting; - /// For external checking. - static size_t const OBJ_SIZE = sizeof(_obj); + /// Size of storage for placement @c new of hashing context. + static size_t const OBJ_SIZE = 256; + +protected: + char _obj[OBJ_SIZE]; /// Raw storage for instantiated context. }; inline bool URLHashContext::update(void const* data, int length) { - return _ctx-update(data, length); + return reinterpret_castCryptoContext*(_obj)-update(data, length); } inline bool URLHashContext::finalize(CryptoHash hash) { - return _ctx-finalize(hash); + return reinterpret_castCryptoContext*(_obj)-finalize(hash); } extern const char *URL_SCHEME_FILE;
git commit: TS-2367: Don't define OCSPContinuation if there is no OCSP support
Repository: trafficserver Updated Branches: refs/heads/master de6bac77d - f5a3d5a2f TS-2367: Don't define OCSPContinuation if there is no OCSP support Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f5a3d5a2 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f5a3d5a2 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f5a3d5a2 Branch: refs/heads/master Commit: f5a3d5a2ff8ada63015748532f6904d6d94ed48e Parents: de6bac7 Author: Bryan Call bc...@apache.org Authored: Fri Aug 1 13:07:27 2014 -0700 Committer: Bryan Call bc...@apache.org Committed: Fri Aug 1 13:08:34 2014 -0700 -- iocore/net/SSLNetProcessor.cc | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f5a3d5a2/iocore/net/SSLNetProcessor.cc -- diff --git a/iocore/net/SSLNetProcessor.cc b/iocore/net/SSLNetProcessor.cc index c6d1a02..06b2cfc 100644 --- a/iocore/net/SSLNetProcessor.cc +++ b/iocore/net/SSLNetProcessor.cc @@ -35,6 +35,7 @@ SSLNetProcessor ssl_NetProcessor; NetProcessor sslNetProcessor = ssl_NetProcessor; EventType SSLNetProcessor::ET_SSL; +#ifdef HAVE_OPENSSL_OCSP_STAPLING struct OCSPContinuation:public Continuation { int mainEvent(int /* event ATS_UNUSED */, Event* /* e ATS_UNUSED */) @@ -49,6 +50,7 @@ struct OCSPContinuation:public Continuation SET_HANDLER(OCSPContinuation::mainEvent); } }; +#endif /* HAVE_OPENSSL_OCSP_STAPLING */ void SSLNetProcessor::cleanup(void)
[11/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/include/ck_stack.h -- diff --git a/lib/ck/include/ck_stack.h b/lib/ck/include/ck_stack.h new file mode 100644 index 000..ac89a95 --- /dev/null +++ b/lib/ck/include/ck_stack.h @@ -0,0 +1,355 @@ +/* + * Copyright 2009-2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _CK_STACK_H +#define _CK_STACK_H + +#include ck_cc.h +#include ck_pr.h +#include stdbool.h +#include stddef.h + +struct ck_stack_entry { + struct ck_stack_entry *next; +}; +typedef struct ck_stack_entry ck_stack_entry_t; + +struct ck_stack { + struct ck_stack_entry *head; + char *generation CK_CC_PACKED; +} CK_CC_ALIASED; +typedef struct ck_stack ck_stack_t; + +#define CK_STACK_INITIALIZER { NULL, NULL } + +#ifndef CK_F_STACK_PUSH_UPMC +#define CK_F_STACK_PUSH_UPMC +/* + * Stack producer operation safe for multiple unique producers and multiple consumers. + */ +CK_CC_INLINE static void +ck_stack_push_upmc(struct ck_stack *target, struct ck_stack_entry *entry) +{ + struct ck_stack_entry *stack; + + stack = ck_pr_load_ptr(target-head); + entry-next = stack; + ck_pr_fence_store(); + + while (ck_pr_cas_ptr_value(target-head, stack, entry, stack) == false) { + entry-next = stack; + ck_pr_fence_store(); + } + + return; +} +#endif /* CK_F_STACK_PUSH_UPMC */ + +#ifndef CK_F_STACK_TRYPUSH_UPMC +#define CK_F_STACK_TRYPUSH_UPMC +/* + * Stack producer operation for multiple unique producers and multiple consumers. + * Returns true on success and false on failure. + */ +CK_CC_INLINE static bool +ck_stack_trypush_upmc(struct ck_stack *target, struct ck_stack_entry *entry) +{ + struct ck_stack_entry *stack; + + stack = ck_pr_load_ptr(target-head); + entry-next = stack; + ck_pr_fence_store(); + + return ck_pr_cas_ptr(target-head, stack, entry); +} +#endif /* CK_F_STACK_TRYPUSH_UPMC */ + +#ifndef CK_F_STACK_POP_UPMC +#define CK_F_STACK_POP_UPMC +/* + * Stack consumer operation safe for multiple unique producers and multiple consumers. + */ +CK_CC_INLINE static struct ck_stack_entry * +ck_stack_pop_upmc(struct ck_stack *target) +{ + struct ck_stack_entry *entry, *next; + + entry = ck_pr_load_ptr(target-head); + if (entry == NULL) + return NULL; + + ck_pr_fence_load(); + next = entry-next; + while (ck_pr_cas_ptr_value(target-head, entry, next, entry) == false) { + if (entry == NULL) + break; + + ck_pr_fence_load(); + next = entry-next; + } + + return entry; +} +#endif + +#ifndef CK_F_STACK_TRYPOP_UPMC +#define CK_F_STACK_TRYPOP_UPMC +/* + * Stack production operation for multiple unique producers and multiple consumers. + * Returns true on success and false on failure. The value pointed to by the second + * argument is set to a valid ck_stack_entry_t reference if true is returned. If + * false is returned, then the value pointed to by the second argument is undefined. + */ +CK_CC_INLINE static bool +ck_stack_trypop_upmc(struct ck_stack *target, struct ck_stack_entry **r) +{ + struct ck_stack_entry *entry; + + entry = ck_pr_load_ptr(target-head); + if (entry == NULL) + return false; + + ck_pr_fence_load(); + if (ck_pr_cas_ptr(target-head, entry, entry-next) == true) { + *r = entry; + return true; + } + + return false; +} +#endif /* CK_F_STACK_TRYPOP_UPMC */ + +#ifndef CK_F_STACK_BATCH_POP_UPMC
[06/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_pflock/benchmark/throughput.c -- diff --git a/lib/ck/regressions/ck_pflock/benchmark/throughput.c b/lib/ck/regressions/ck_pflock/benchmark/throughput.c new file mode 100644 index 000..6c0ed6c --- /dev/null +++ b/lib/ck/regressions/ck_pflock/benchmark/throughput.c @@ -0,0 +1,163 @@ +/* + * Copyright 2011-2014 Samy Al Bahra. + * Copyright 2013 John Wittrock. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHEPFISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include ck_pflock.h +#include inttypes.h +#include pthread.h +#include stdio.h +#include stdint.h +#include stdlib.h +#include unistd.h + +#include ../../common.h + +#ifndef STEPS +#define STEPS 100 +#endif + +static int barrier; +static int threads; +static unsigned int flag CK_CC_CACHELINE; +static ck_pflock_t pflock = CK_PFLOCK_INITIALIZER; +static struct affinity affinity; + +static void * +thread_pflock(void *pun) +{ + uint64_t s_b, e_b, a, i; + uint64_t *value = pun; + + if (aff_iterate(affinity) != 0) { + perror(ERROR: Could not affine thread); + exit(EXIT_FAILURE); + } + + ck_pr_inc_int(barrier); + while (ck_pr_load_int(barrier) != threads) + ck_pr_stall(); + + for (i = 1, a = 0;; i++) { + s_b = rdtsc(); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + ck_pflock_read_lock(pflock); + ck_pflock_read_unlock(pflock); + e_b = rdtsc(); + + a += (e_b - s_b) 4; + + if (ck_pr_load_uint(flag) == 1) + break; + } + + ck_pr_inc_int(barrier); + while (ck_pr_load_int(barrier) != threads * 2) + ck_pr_stall(); + + *value = (a / i); + return NULL; +} + +int +main(int argc, char *argv[]) +{ + int t; + pthread_t *p; + uint64_t *latency; + + if (argc != 3) { + ck_error(Usage: throughput delta threads\n); + } + + threads = atoi(argv[2]); + if (threads = 0) { + ck_error(ERROR: Threads must be a value 0.\n); + } + + p = malloc(sizeof(pthread_t) * threads); + if (p == NULL) { + ck_error(ERROR: Failed to initialize thread.\n); + } + + latency
[09/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_array/validate/serial.c -- diff --git a/lib/ck/regressions/ck_array/validate/serial.c b/lib/ck/regressions/ck_array/validate/serial.c new file mode 100644 index 000..b6d7b56 --- /dev/null +++ b/lib/ck/regressions/ck_array/validate/serial.c @@ -0,0 +1,178 @@ +#include ck_array.h +#include limits.h +#include stdio.h +#include stdlib.h + +#include ../../common.h + +#ifndef ITERATION +#define ITERATION 128 +#endif + +static void +my_free(void *p, size_t m, bool d) +{ + + (void)m; + (void)d; + + free(p); + return; +} + +static void * +my_malloc(size_t b) +{ + + return malloc(b); +} + +static void * +my_realloc(void *r, size_t a, size_t b, bool d) +{ + + (void)a; + (void)d; + + return realloc(r, b); +} + +int +main(void) +{ + void *r; + uintptr_t i; + ck_array_t array; + ck_array_iterator_t iterator; + struct ck_malloc m = { + .malloc = my_malloc, + .free = NULL, + .realloc = my_realloc + }; + + if (ck_array_init(array, CK_ARRAY_MODE_SPMC, m, 4) == true) + ck_error(ck_array_init with NULL free succeeded\n); + + m.free = my_free; + if (ck_array_init(array, CK_ARRAY_MODE_SPMC, m, 4) == false) + ck_error(ck_array_init\n); + + for (i = 0; i ITERATION; i++) { + if (ck_array_put(array, (void *)i) == false) + ck_error(ck_error_put\n); + + if (ck_array_remove(array, (void *)i) == false) + ck_error(ck_error_remove after put\n); + } + + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != 0) + ck_error(Non-empty array after put - remove workload.\n); + + ck_array_commit(array); + + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != 0) + ck_error(Non-empty array after put - remove - commit workload.\n); + + for (i = 0; i ITERATION; i++) { + if (ck_array_put(array, (void *)i) == false) + ck_error(ck_error_put\n); + } + + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != 0) + ck_error(Non-empty array after put workload.\n); + + for (i = 0; i ITERATION; i++) { + if (ck_array_remove(array, (void *)i) == false) + ck_error(ck_error_remove after put\n); + } + + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != 0) + ck_error(Non-empty array after put - remove workload.\n); + + ck_array_commit(array); + + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != 0) + ck_error(Non-empty array after put - remove - commit workload.\n); + + for (i = 0; i ITERATION; i++) { + if (ck_array_put(array, (void *)i) == false) + ck_error(ck_error_put\n); + } + + ck_array_commit(array); + + i = 0; + CK_ARRAY_FOREACH(array, iterator, r) { + i++; + } + + if (i != ITERATION) + ck_error(Incorrect item count in iteration\n); + + ck_array_remove(array, (void *)(uintptr_t)0); + ck_array_remove(array, (void *)(uintptr_t)1); + ck_array_commit(array); + i = 0; CK_ARRAY_FOREACH(array, iterator, r) i++; + if (i != ITERATION - 2 || ck_array_length(array) != ITERATION - 2) + ck_error(Incorrect item count in iteration after remove\n); + + if (ck_array_put_unique(array, (void *)UINTPTR_MAX) != 0) + ck_error(Unique value put failed.\n); + + if (ck_array_put_unique(array, (void *)(uintptr_t)4) != 1) + ck_error(put of 4 not detected as non-unique.\n); + + if (ck_array_put_unique(array, (void *)UINTPTR_MAX) != 1) + ck_error(put of UINTPTR_MAX not detected as non-unique.\n); + + ck_array_commit(array); + i = 0; + CK_ARRAY_FOREACH(array, iterator, r) { + i++; + } + if (i != ITERATION - 1 || ck_array_length(array) != ITERATION - 1) + ck_error(Incorrect item count in iteration after unique put\n); + + if (ck_array_initialized(array) == false) + ck_error(Error, expected array to be initialized.\n); + + for (i = 0; i ITERATION * 4; i++) { + ck_array_remove(array, (void *)i); + } + + for (i = 0; i ITERATION * 16; i++) { + ck_array_put(array, (void *)i); + } + + ck_array_commit(array); + + for (i = 0; i ITERATION * 128; i++) { + ck_array_put(array, (void *)i); + if (ck_array_put_unique(array, (void *)i) != 1) + ck_error(put_unique for non-unique value should fail.\n); + } + +
[01/20] TS-2950: Initial commit of libck.
Repository: trafficserver Updated Branches: refs/heads/master f5a3d5a2f - f098175e9 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/src/ck_ht.c -- diff --git a/lib/ck/src/ck_ht.c b/lib/ck/src/ck_ht.c new file mode 100644 index 000..ea9de1e --- /dev/null +++ b/lib/ck/src/ck_ht.c @@ -0,0 +1,1030 @@ +/* + * Copyright 2012-2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include ck_ht.h + +#ifdef CK_F_HT +/* + * This implementation borrows several techniques from Josh Dybnis's + * nbds library which can be found at http://code.google.com/p/nbds + * + * This release currently only includes support for 64-bit platforms. + * We can address 32-bit platforms in a future release. + */ +#include ck_cc.h +#include ck_md.h +#include ck_pr.h +#include ck_stdint.h +#include stdbool.h +#include string.h + +#include ck_ht_hash.h +#include ck_internal.h + +#ifndef CK_HT_BUCKET_LENGTH + +#ifdef CK_HT_PP +#define CK_HT_BUCKET_SHIFT 2ULL +#else +#define CK_HT_BUCKET_SHIFT 1ULL +#endif + +#define CK_HT_BUCKET_LENGTH (1U CK_HT_BUCKET_SHIFT) +#define CK_HT_BUCKET_MASK (CK_HT_BUCKET_LENGTH - 1) +#endif + +#ifndef CK_HT_PROBE_DEFAULT +#define CK_HT_PROBE_DEFAULT 64ULL +#endif + +#if defined(CK_F_PR_LOAD_8) defined(CK_F_PR_STORE_8) +#define CK_HT_WORD uint8_t +#define CK_HT_WORD_MAX UINT8_MAX +#define CK_HT_STORE(x, y) ck_pr_store_8(x, y) +#define CK_HT_LOAD(x) ck_pr_load_8(x) +#elif defined(CK_F_PR_LOAD_16) defined(CK_F_PR_STORE_16) +#define CK_HT_WORD uint16_t +#define CK_HT_WORD_MAX UINT16_MAX +#define CK_HT_STORE(x, y) ck_pr_store_16(x, y) +#define CK_HT_LOAD(x) ck_pr_load_16(x) +#elif defined(CK_F_PR_LOAD_32) defined(CK_F_PR_STORE_32) +#define CK_HT_WORD uint32_t +#define CK_HT_WORD_MAX UINT32_MAX +#define CK_HT_STORE(x, y) ck_pr_store_32(x, y) +#define CK_HT_LOAD(x) ck_pr_load_32(x) +#else +#error ck_ht is not supported on your platform. +#endif + +struct ck_ht_map { + unsigned int mode; + uint64_t deletions; + uint64_t probe_maximum; + uint64_t probe_length; + uint64_t probe_limit; + uint64_t size; + uint64_t n_entries; + uint64_t mask; + uint64_t capacity; + uint64_t step; + CK_HT_WORD *probe_bound; + struct ck_ht_entry *entries; +}; + +void +ck_ht_stat(struct ck_ht *table, +struct ck_ht_stat *st) +{ + struct ck_ht_map *map = table-map; + + st-n_entries = map-n_entries; + st-probe_maximum = map-probe_maximum; + return; +} + +void +ck_ht_hash(struct ck_ht_hash *h, +struct ck_ht *table, +const void *key, +uint16_t key_length) +{ + + h-value = MurmurHash64A(key, key_length, table-seed); + return; +} + +void +ck_ht_hash_direct(struct ck_ht_hash *h, +struct ck_ht *table, +uintptr_t key) +{ + + ck_ht_hash(h, table, key, sizeof(key)); + return; +} + +static void +ck_ht_hash_wrapper(struct ck_ht_hash *h, +const void *key, +size_t length, +uint64_t seed) +{ + + h-value = MurmurHash64A(key, length, seed); + return; +} + +static struct ck_ht_map * +ck_ht_map_create(struct ck_ht *table, uint64_t entries) +{ + struct ck_ht_map *map; + uint64_t size, n_entries, prefix; + + n_entries = ck_internal_power_2(entries); + if (n_entries CK_HT_BUCKET_LENGTH) + return NULL; + + size = sizeof(struct ck_ht_map) + + (sizeof(struct ck_ht_entry) * n_entries + CK_MD_CACHELINE - 1); + + if (table-mode CK_HT_WORKLOAD_DELETE) { + prefix = sizeof(CK_HT_WORD) *
[07/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_hs/benchmark/parallel_bytestring.c -- diff --git a/lib/ck/regressions/ck_hs/benchmark/parallel_bytestring.c b/lib/ck/regressions/ck_hs/benchmark/parallel_bytestring.c new file mode 100644 index 000..ea2eaec --- /dev/null +++ b/lib/ck/regressions/ck_hs/benchmark/parallel_bytestring.c @@ -0,0 +1,602 @@ +/* + * Copyright 2012 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyrighs + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyrighs + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include ../../common.h +#include ck_hs.h +#include ../../../src/ck_ht_hash.h +#include assert.h +#include ck_epoch.h +#include ck_malloc.h +#include ck_pr.h +#include ck_spinlock.h + +#include errno.h +#include inttypes.h +#include pthread.h +#include signal.h +#include stdio.h +#include stdlib.h +#include string.h +#include time.h +#include unistd.h + +static ck_hs_t hs CK_CC_CACHELINE; +static char **keys; +static size_t keys_length = 0; +static size_t keys_capacity = 128; +static ck_epoch_t epoch_hs; +static ck_epoch_record_t epoch_wr; +static int n_threads; +static bool next_stage; + +enum state { + HS_STATE_STOP = 0, + HS_STATE_GET, + HS_STATE_STRICT_REPLACEMENT, + HS_STATE_DELETION, + HS_STATE_REPLACEMENT, + HS_STATE_COUNT +}; + +static ck_spinlock_t mtx = CK_SPINLOCK_INITIALIZER; +static struct affinity affinerator = AFFINITY_INITIALIZER; +static uint64_t accumulator[HS_STATE_COUNT]; +static int barrier[HS_STATE_COUNT]; +static int state; + +struct hs_epoch { + ck_epoch_entry_t epoch_entry; +}; + +COMMON_ALARM_DECLARE_GLOBAL(hs_alarm, alarm_event, next_stage) + +static void +alarm_handler(int s) +{ + + (void)s; + next_stage = true; + return; +} + +static unsigned long +hs_hash(const void *object, unsigned long seed) +{ + const char *c = object; + unsigned long h; + + h = (unsigned long)MurmurHash64A(c, strlen(c), seed); + return h; +} + +static bool +hs_compare(const void *previous, const void *compare) +{ + + return strcmp(previous, compare) == 0; +} + +static void +hs_destroy(ck_epoch_entry_t *e) +{ + + free(e); + return; +} + +static void * +hs_malloc(size_t r) +{ + ck_epoch_entry_t *b; + + b = malloc(sizeof(*b) + r); + return b + 1; +} + +static void +hs_free(void *p, size_t b, bool r) +{ + struct hs_epoch *e = p; + + (void)b; + + if (r == true) { + /* Destruction requires safe memory reclamation. */ + ck_epoch_call(epoch_hs, epoch_wr, (--e)-epoch_entry, hs_destroy); + } else { + free(--e); + } + + return; +} + +static struct ck_malloc my_allocator = { + .malloc = hs_malloc, + .free = hs_free +}; + +static void +set_init(void) +{ + unsigned int mode = CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC; + +#ifdef HS_DELETE + mode |= CK_HS_MODE_DELETE; +#endif + + ck_epoch_init(epoch_hs); + ck_epoch_register(epoch_hs, epoch_wr); + common_srand48((long int)time(NULL)); + if (ck_hs_init(hs, mode, hs_hash, hs_compare, my_allocator, 65536, common_lrand48()) == false) { + perror(ck_hs_init); + exit(EXIT_FAILURE); + } + + return; +} + +static bool +set_remove(const char *value) +{ + unsigned long h; + + h = CK_HS_HASH(hs, hs_hash, value); + return (bool)ck_hs_remove(hs, h, value); +} + +static bool +set_replace(const char *value) +{ + unsigned long h; + void *previous; + + h = CK_HS_HASH(hs, hs_hash, value); + return ck_hs_set(hs, h, value, previous); +} + +static bool +set_swap(const
[03/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_fas.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_fas.h b/lib/ck/regressions/ck_spinlock/ck_fas.h new file mode 100644 index 000..e244746 --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_fas.h @@ -0,0 +1,6 @@ +#define LOCK_NAME ck_fas +#define LOCK_DEFINE static ck_spinlock_fas_t CK_CC_CACHELINE lock = CK_SPINLOCK_FAS_INITIALIZER +#define LOCK ck_spinlock_fas_lock_eb(lock) +#define UNLOCK ck_spinlock_fas_unlock(lock) +#define LOCKED ck_spinlock_fas_locked(lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_hclh.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_hclh.h b/lib/ck/regressions/ck_spinlock/ck_hclh.h new file mode 100644 index 000..eb2e6eb --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_hclh.h @@ -0,0 +1,16 @@ +#define MAX(a,b) ((a) (b) ? (a) : (b)) +#define LOCK_NAME ck_clh +#define LOCK_DEFINE static ck_spinlock_hclh_t CK_CC_CACHELINE *glob_lock; \ + static ck_spinlock_hclh_t CK_CC_CACHELINE *local_lock[CORES / 2] +#define LOCK_STATE ck_spinlock_hclh_t *na = malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)) +#define LOCK ck_spinlock_hclh_lock(glob_lock, local_lock[(core % CORES) / 2], na) +#define UNLOCK ck_spinlock_hclh_unlock(na) +#define LOCK_INIT do { \ + int _i; \ + ck_spinlock_hclh_init(glob_lock, malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), -1); \ + for (_i = 0; _i CORES / 2; _i++) {\ + ck_spinlock_hclh_init(local_lock[_i], malloc(MAX(sizeof(ck_spinlock_hclh_t), 64)), _i);} \ +} while (0) + +#define LOCKED ck_spinlock_hclh_locked(glob_lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_mcs.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_mcs.h b/lib/ck/regressions/ck_spinlock/ck_mcs.h new file mode 100644 index 000..dd127df --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_mcs.h @@ -0,0 +1,7 @@ +#define LOCK_NAME ck_mcs +#define LOCK_DEFINE static ck_spinlock_mcs_t CK_CC_CACHELINE lock = NULL +#define LOCK_STATE ck_spinlock_mcs_context_t node CK_CC_CACHELINE; +#define LOCK ck_spinlock_mcs_lock(lock, node) +#define UNLOCK ck_spinlock_mcs_unlock(lock, node) +#define LOCKED ck_spinlock_mcs_locked(lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_spinlock.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_spinlock.h b/lib/ck/regressions/ck_spinlock/ck_spinlock.h new file mode 100644 index 000..938e1ce --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_spinlock.h @@ -0,0 +1,6 @@ +#define LOCK_NAME ck_spinlock +#define LOCK_DEFINE static ck_spinlock_t CK_CC_CACHELINE lock = CK_SPINLOCK_INITIALIZER +#define LOCK ck_spinlock_lock_eb(lock) +#define UNLOCK ck_spinlock_unlock(lock) +#define LOCKED ck_spinlock_locked(lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_ticket.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_ticket.h b/lib/ck/regressions/ck_spinlock/ck_ticket.h new file mode 100644 index 000..39054a6 --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_ticket.h @@ -0,0 +1,11 @@ +#include ck_spinlock.h + +#define LOCK_NAME ck_ticket +#define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER +#define LOCK ck_spinlock_ticket_lock(lock) +#define UNLOCK ck_spinlock_ticket_unlock(lock) +#ifdef CK_F_SPINLOCK_TICKET_TRYLOCK +#define TRYLOCK ck_spinlock_ticket_trylock(lock) +#endif +#define LOCKED ck_spinlock_ticket_locked(lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/ck_ticket_pb.h -- diff --git a/lib/ck/regressions/ck_spinlock/ck_ticket_pb.h b/lib/ck/regressions/ck_spinlock/ck_ticket_pb.h new file mode 100644 index 000..b8a7a84 --- /dev/null +++ b/lib/ck/regressions/ck_spinlock/ck_ticket_pb.h @@ -0,0 +1,6 @@ +#define LOCK_NAME ck_ticket_pb +#define LOCK_DEFINE static ck_spinlock_ticket_t CK_CC_CACHELINE lock = CK_SPINLOCK_TICKET_INITIALIZER +#define LOCK ck_spinlock_ticket_lock_pb(lock, 0) +#define UNLOCK ck_spinlock_ticket_unlock(lock) +#define LOCKED ck_spinlock_ticket_locked(lock) + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_spinlock/linux_spinlock.h
[19/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/CK_COHORT_UNLOCK -- diff --git a/lib/ck/doc/CK_COHORT_UNLOCK b/lib/ck/doc/CK_COHORT_UNLOCK new file mode 100644 index 000..6c5440a --- /dev/null +++ b/lib/ck/doc/CK_COHORT_UNLOCK @@ -0,0 +1,61 @@ +.\ +.\ Copyright 2013 Brendon Scheinman. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd February 24, 2013. +.Dt CK_COHORT_UNLOCK 3 +.Sh NAME +.Nm CK_COHORT_UNLOCK +.Nd release cohort lock +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_cohort.h +.Fn CK_COHORT_UNLOCK COHORT_NAME cohort_name COHORT *cohort void *global_context \ +void *local_context +.Sh DESCRIPTION +This call instructs +.Fa cohort +to relinquish its local lock and potentially its global lock as well. +.Fa global_context +will be passed as the second argument to the function that was provided as the +.Fa global_lock_method +argument to CK_COHORT_PROTOTYPE if that method is called, and +.Fa local_context +will be passed to the function specified by +.Fa local_lock_method +. +.Sh SEE ALSO +.Xr ck_cohort 3 , +.Xr CK_COHORT_PROTOTYPE 3 , +.Xr CK_COHORT_TRYLOCK_PROTOTYPE 3 , +.Xr CK_COHORT_INSTANCE 3 , +.Xr CK_COHORT_INITIALIZER 3 , +.Xr CK_COHORT_INIT 3 , +.Xr CK_COHORT_LOCK 3 , +.Xr CK_COHORT_LOCKED 3 , +.Xr CK_COHORT_TRYLOCK 3 , +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/CK_HS_HASH -- diff --git a/lib/ck/doc/CK_HS_HASH b/lib/ck/doc/CK_HS_HASH new file mode 100644 index 000..6d8dc75 --- /dev/null +++ b/lib/ck/doc/CK_HS_HASH @@ -0,0 +1,71 @@ +.\ +.\ Copyright 2012-2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd March 28, 2012 +.Dt CK_HS_HASH 3 +.Sh NAME +.Nm CK_HS_HASH +.Nd invoke hash function with hash set seed +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_hs.h +.Ft unsigned long +.Fn CK_HS_HASH ck_hs_t *hs ck_hs_hash_cb_t *hf const void *key +.Sh DESCRIPTION +The +.Fn CK_HS_HASH 3 +macro will invoke the hash function pointed to by the +.Fa hf +argument with the seed value associated with +.Fa hs +and the key pointer specified by the +.Fa key +argument. +.Sh RETURN VALUES +This function will return the value
[02/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/common.h -- diff --git a/lib/ck/regressions/common.h b/lib/ck/regressions/common.h new file mode 100644 index 000..f100e89 --- /dev/null +++ b/lib/ck/regressions/common.h @@ -0,0 +1,457 @@ +/* + * Copyright 2011-2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include ck_cc.h +#include ck_pr.h +#include stdarg.h +#include stdio.h +#include stdlib.h +#include sys/time.h + +#ifdef __linux__ +#include sched.h +#include sys/types.h +#include sys/syscall.h +#elif defined(__MACH__) +#include mach/mach.h +#include mach/thread_policy.h +#elif defined(__FreeBSD__) +#include sys/param.h +#include sys/cpuset.h +#endif + +#if defined(_WIN32) +#include assert.h +#define NOMINMAX +#include windows.h +#define DELTA_EPOCH 116444736ULL +#else +#include signal.h +#include unistd.h +#endif + +#ifndef CORES +#define CORES 8 +#endif + +CK_CC_INLINE static void +common_srand(unsigned int i) +{ +#ifdef _WIN32 + srand(i); +#else + srandom(i); +#endif +} + +CK_CC_INLINE static int +common_rand(void) +{ +#ifdef _WIN32 + return rand(); +#else + return random(); +#endif +} + +CK_CC_INLINE static int +common_rand_r(unsigned int *i) +{ +#ifdef _WIN32 + (void)i; + + /* +* When linked with -mthreads, rand() is thread-safe. +* rand_s is also an option. +*/ + return rand(); +#else + return rand_r(i); +#endif +} + +CK_CC_INLINE static void +common_srand48(long int i) +{ +#ifdef _WIN32 + srand(i); +#else + srand48(i); +#endif +} + +CK_CC_INLINE static long int +common_lrand48(void) +{ +#ifdef _WIN32 + return rand(); +#else + return lrand48(); +#endif +} + +CK_CC_INLINE static double +common_drand48(void) +{ +#ifdef _WIN32 + return (double)rand()/RAND_MAX; +#else + return drand48(); +#endif +} + +CK_CC_INLINE static void +common_sleep(unsigned int n) +{ +#ifdef _WIN32 + Sleep(n * 1000); +#else + sleep(n); +#endif +} + +CK_CC_INLINE static int +common_gettimeofday(struct timeval *tv, void *tz) +{ +#ifdef _WIN32 + FILETIME ft; + uint64_t tmp_time = 0; + static bool tzflag = false; + struct timezone *tzp = tz; + + if (tv != NULL) { + GetSystemTimeAsFileTime(ft); + tmp_time |= ft.dwHighDateTime; + tmp_time = 32; + tmp_time |= ft.dwLowDateTime; + + /* GetSystemTimeAsFileTime returns 100 nanosecond intervals. */ + tmp_time /= 10; + + /* Windows' epoch starts on 01/01/1601, while Unix' starts on 01/01/1970. */ + tmp_time -= DELTA_EPOCH; + + tv-tv_sec = (long)(tmp_time / 100UL); + tv-tv_usec = (long)(tmp_time % 100UL); + } + + + if (tz != NULL) { + if (tzflag == false) { + _tzset(); + tzflag = true; + } + + tzp-tz_minuteswest = _timezone / 60; + tzp-tz_dsttime = _daylight; + } + + return 0; +#else + return gettimeofday(tv, tz); +#endif +} + +CK_CC_UNUSED static unsigned int +common_alarm(void (*sig_handler)(int), void *alarm_event, unsigned int duration) +{ +#ifdef _WIN32 + (void)sig_handler; + (void)duration; + bool success; + HANDLE *alarm_handle = alarm_event; + success = SetEvent(*alarm_handle); + assert(success != false); + return 0; +#else + (void)alarm_event; + signal(SIGALRM, sig_handler); + return
[12/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/include/ck_pr.h -- diff --git a/lib/ck/include/ck_pr.h b/lib/ck/include/ck_pr.h new file mode 100644 index 000..eb198f5 --- /dev/null +++ b/lib/ck/include/ck_pr.h @@ -0,0 +1,1152 @@ +/* + * Copyright 2009-2014 Samy Al Bahra. + * Copyright 2011 David Joseph. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _CK_PR_H +#define _CK_PR_H + +#include ck_cc.h +#include ck_limits.h +#include ck_md.h +#include ck_stdint.h +#include stdbool.h + +#if defined(__x86_64__) +#include gcc/x86_64/ck_pr.h +#elif defined(__x86__) +#include gcc/x86/ck_pr.h +#elif defined(__sparcv9__) +#include gcc/sparcv9/ck_pr.h +#elif defined(__ppc64__) +#include gcc/ppc64/ck_pr.h +#elif defined(__ppc__) +#include gcc/ppc/ck_pr.h +#elif defined(__arm__) +#include gcc/arm/ck_pr.h +#elif !defined(__GNUC__) +#error Your platform is unsupported +#endif + +#if defined(__GNUC__) +#include gcc/ck_pr.h +#endif + +#define CK_PR_FENCE_EMIT(T)\ + CK_CC_INLINE static void\ + ck_pr_fence_##T(void) \ + { \ + ck_pr_fence_strict_##T(); \ + return; \ + } +#define CK_PR_FENCE_NOOP(T)\ + CK_CC_INLINE static void\ + ck_pr_fence_##T(void) \ + { \ + ck_pr_barrier();\ + return; \ + } + +/* + * None of the currently supported platforms allow for data-dependent + * load ordering. + */ +CK_PR_FENCE_NOOP(load_depends) +#define ck_pr_fence_strict_load_depends ck_pr_fence_load_depends + +/* + * In memory models where atomic operations do not have serializing + * effects, atomic read-modify-write operations are modeled as stores. + */ +#if defined(CK_MD_RMO) +/* + * Only stores to the same location have a global + * ordering. + */ +CK_PR_FENCE_EMIT(atomic) +CK_PR_FENCE_EMIT(atomic_load) +CK_PR_FENCE_EMIT(atomic_store) +CK_PR_FENCE_EMIT(store_atomic) +CK_PR_FENCE_EMIT(load_atomic) +CK_PR_FENCE_EMIT(load_store) +CK_PR_FENCE_EMIT(store_load) +CK_PR_FENCE_EMIT(load) +CK_PR_FENCE_EMIT(store) +CK_PR_FENCE_EMIT(memory) +CK_PR_FENCE_EMIT(acquire) +CK_PR_FENCE_EMIT(release) +#elif defined(CK_MD_PSO) +/* + * Anything can be re-ordered with respect to stores. + * Otherwise, loads are executed in-order. + */ +CK_PR_FENCE_EMIT(atomic) +CK_PR_FENCE_NOOP(atomic_load) +CK_PR_FENCE_EMIT(atomic_store) +CK_PR_FENCE_EMIT(store_atomic) +CK_PR_FENCE_NOOP(load_atomic) +CK_PR_FENCE_EMIT(load_store) +CK_PR_FENCE_EMIT(store_load) +CK_PR_FENCE_NOOP(load) +CK_PR_FENCE_EMIT(store) +CK_PR_FENCE_EMIT(memory) +CK_PR_FENCE_EMIT(acquire) +CK_PR_FENCE_EMIT(release) +#elif defined(CK_MD_TSO) +/* + * Only loads are re-ordered and only with respect to + * prior stores. Atomic operations are serializing. + */ +CK_PR_FENCE_NOOP(atomic) +CK_PR_FENCE_NOOP(atomic_load) +CK_PR_FENCE_NOOP(atomic_store) +CK_PR_FENCE_NOOP(store_atomic) +CK_PR_FENCE_NOOP(load_atomic) +CK_PR_FENCE_NOOP(load_store) +CK_PR_FENCE_EMIT(store_load) +CK_PR_FENCE_NOOP(load) +CK_PR_FENCE_NOOP(store) +CK_PR_FENCE_NOOP(memory) +CK_PR_FENCE_NOOP(acquire) +CK_PR_FENCE_NOOP(release) +#else +#error No memory model has been defined. +#endif /* CK_MD_TSO */ + +#undef CK_PR_FENCE_EMIT +#undef CK_PR_FENCE_NOOP + +#define CK_PR_BIN(K, S, M, T, P, C)\ + CK_CC_INLINE static void\ + ck_pr_##K##_##S(M
[15/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_pr_fence_atomic_store -- diff --git a/lib/ck/doc/ck_pr_fence_atomic_store b/lib/ck/doc/ck_pr_fence_atomic_store new file mode 100644 index 000..a14867c --- /dev/null +++ b/lib/ck/doc/ck_pr_fence_atomic_store @@ -0,0 +1,109 @@ +.\ +.\ Copyright 2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd May 16, 2013 +.Dt CK_PR_FENCE_ATOMIC_STORE 3 +.Sh NAME +.Nm ck_pr_fence_atomic_store +.Nd enforce ordering of atomic read-modify-write operations to store operations +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_pr.h +.Ft void +.Fn ck_pr_fence_atomic_store void +.Ft void +.Fn ck_pr_fence_strict_atomic_store void +.Sh DESCRIPTION +The +.Fn ck_pr_fence_atomic_store +function enfores the ordering of any +atomic read-modify-write operations relative to +any load operations following the function invocation. This function +always serve as an implicit compiler barrier. On +architectures implementing CK_MD_TSO, this operation +only serves as a compiler barrier and no fences +are emitted. To force the unconditional emission of +a fence, use +.Fn ck_pr_fence_strict_atomic_store . +.Sh EXAMPLE +.Bd -literal -offset indent + +#include ck_pr.h + +static int a = 0; +static int b = 0; + +void +function(void) +{ + int c; + + ck_pr_fas_int(a, 1); + + /* +* Guarantee that the update to a is completed +* with respect to the store into the value pointed +* to by b. +*/ + ck_pr_fence_atomic_store(); + c = ck_pr_store_int(b, 2); + + return; +} +.Ed +.Sh RETURN VALUES +This function has no return value. +.Sh SEE ALSO +.Xr ck_pr_stall 3 , +.Xr ck_pr_fence_atomic 3 , +.Xr ck_pr_fence_atomic_load 3 , +.Xr ck_pr_fence_store 3 , +.Xr ck_pr_fence_load 3 , +.Xr ck_pr_fence_load_atomic 3 , +.Xr ck_pr_fence_load_store 3 , +.Xr ck_pr_fence_load_depends 3 , +.Xr ck_pr_fence_memory 3 , +.Xr ck_pr_barrier 3 , +.Xr ck_pr_fas 3 , +.Xr ck_pr_load 3 , +.Xr ck_pr_store 3 , +.Xr ck_pr_faa 3 , +.Xr ck_pr_inc 3 , +.Xr ck_pr_dec 3 , +.Xr ck_pr_neg 3 , +.Xr ck_pr_not 3 , +.Xr ck_pr_add 3 , +.Xr ck_pr_sub 3 , +.Xr ck_pr_and 3 , +.Xr ck_pr_or 3 , +.Xr ck_pr_xor 3 , +.Xr ck_pr_cas 3 , +.Xr ck_pr_btc 3 , +.Xr ck_pr_bts 3 , +.Xr ck_pr_btr 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_pr_fence_load -- diff --git a/lib/ck/doc/ck_pr_fence_load b/lib/ck/doc/ck_pr_fence_load new file mode 100644 index 000..da8e6d4 --- /dev/null +++ b/lib/ck/doc/ck_pr_fence_load @@ -0,0 +1,113 @@ +.\ +.\ Copyright 2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\
[08/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_epoch/validate/Makefile -- diff --git a/lib/ck/regressions/ck_epoch/validate/Makefile b/lib/ck/regressions/ck_epoch/validate/Makefile new file mode 100644 index 000..73f8e5d --- /dev/null +++ b/lib/ck/regressions/ck_epoch/validate/Makefile @@ -0,0 +1,26 @@ +.PHONY: check clean distribution + +OBJECTS=ck_stack ck_epoch_synchronize ck_epoch_poll +HALF=`expr $(CORES) / 2` + +all: $(OBJECTS) + +check: all + ./ck_stack $(CORES) 1 + ./ck_epoch_synchronize $(HALF) $(HALF) 1 + ./ck_epoch_poll $(CORES) 1 1 + +ck_epoch_synchronize: ck_epoch_synchronize.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c + $(CC) $(CFLAGS) -o ck_epoch_synchronize ck_epoch_synchronize.c ../../../src/ck_epoch.c + +ck_epoch_poll: ck_epoch_poll.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c + $(CC) $(CFLAGS) -o ck_epoch_poll ck_epoch_poll.c ../../../src/ck_epoch.c + +ck_stack: ck_stack.c ../../../include/ck_stack.h ../../../include/ck_epoch.h ../../../src/ck_epoch.c + $(CC) $(CFLAGS) -o ck_stack ck_stack.c ../../../src/ck_epoch.c + +clean: + rm -rf *~ *.o $(OBJECTS) *.dSYM *.exe + +include ../../../build/regressions.build +CFLAGS+=$(PTHREAD_CFLAGS) -D_GNU_SOURCE http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_epoch/validate/ck_epoch_poll.c -- diff --git a/lib/ck/regressions/ck_epoch/validate/ck_epoch_poll.c b/lib/ck/regressions/ck_epoch/validate/ck_epoch_poll.c new file mode 100644 index 000..86cdbb4 --- /dev/null +++ b/lib/ck/regressions/ck_epoch/validate/ck_epoch_poll.c @@ -0,0 +1,245 @@ +/* + * Copyright 2010-2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include errno.h +#include inttypes.h +#include pthread.h +#include stdint.h +#include stdio.h +#include stdlib.h +#include strings.h +#include unistd.h +#include sys/time.h + +#include ck_backoff.h +#include ck_cc.h +#include ck_pr.h +#include stdbool.h +#include stddef.h +#include string.h +#include ck_epoch.h +#include ck_stack.h + +#include ../../common.h + +static unsigned int n_rd; +static unsigned int n_wr; +static unsigned int n_threads; +static unsigned int barrier; +static unsigned int e_barrier; +static unsigned int readers; +static unsigned int writers; + +#ifndef PAIRS_S +#define PAIRS_S 10 +#endif + +#ifndef ITERATE_S +#define ITERATE_S 20 +#endif + +struct node { + unsigned int value; + ck_stack_entry_t stack_entry; + ck_epoch_entry_t epoch_entry; +}; +static ck_stack_t stack = CK_STACK_INITIALIZER; +static ck_epoch_t stack_epoch; +CK_STACK_CONTAINER(struct node, stack_entry, stack_container) +CK_EPOCH_CONTAINER(struct node, epoch_entry, epoch_container) +static struct affinity a; +static const char animate[] = -/|\\; + +static void +destructor(ck_epoch_entry_t *p) +{ + struct node *e = epoch_container(p); + + free(e); + return; +} + +static void * +read_thread(void *unused CK_CC_UNUSED) +{ + unsigned int j; + ck_epoch_record_t record CK_CC_CACHELINE; + ck_stack_entry_t *cursor; + + /* +* This is redundant post-incremented in order to silence some +* irrelevant GCC warnings. It is volatile in order to prevent +* elimination. +*/ + volatile ck_stack_entry_t *n; + + ck_epoch_register(stack_epoch, record); + + if (aff_iterate(a)) { + perror(ERROR: failed to affine thread); +
[04/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_ring/validate/ck_ring_spsc.c -- diff --git a/lib/ck/regressions/ck_ring/validate/ck_ring_spsc.c b/lib/ck/regressions/ck_ring/validate/ck_ring_spsc.c new file mode 100644 index 000..b107c3c --- /dev/null +++ b/lib/ck/regressions/ck_ring/validate/ck_ring_spsc.c @@ -0,0 +1,213 @@ +/* + * Copyright 2011-2014 Samy Al Bahra. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include assert.h +#include stdlib.h +#include stdio.h +#include pthread.h + +#include ck_barrier.h +#include ck_ring.h +#include ../../common.h + +#ifndef ITERATIONS +#define ITERATIONS 128 +#endif + +struct context { + unsigned int tid; + unsigned int previous; + unsigned int next; + void *buffer; +}; + +struct entry { + int tid; + int value; +}; + +static int nthr; +static ck_ring_t *ring; +static struct affinity a; +static int size; +static ck_barrier_centralized_t barrier = CK_BARRIER_CENTRALIZED_INITIALIZER; +static struct context *_context; + +static void * +test(void *c) +{ + struct context *context = c; + struct entry *entry; + unsigned int s; + int i, j; + bool r; + ck_barrier_centralized_state_t sense = + CK_BARRIER_CENTRALIZED_STATE_INITIALIZER; + ck_ring_buffer_t *buffer; + +if (aff_iterate(a)) { +perror(ERROR: Could not affine thread); +exit(EXIT_FAILURE); +} + + buffer = context-buffer; + if (context-tid == 0) { + struct entry *entries; + + entries = malloc(sizeof(struct entry) * size); + assert(entries != NULL); + + if (ck_ring_size(ring) != 0) { + ck_error(More entries than expected: %u 0\n, + ck_ring_size(ring)); + } + + for (i = 0; i size; i++) { + entries[i].value = i; + entries[i].tid = 0; + + if (i 1) { + r = ck_ring_enqueue_spsc(ring, buffer, + entries + i); + } else { + r = ck_ring_enqueue_spsc_size(ring, + buffer, entries + i, s); + + if ((int)s != i) { + ck_error(Size is %u, expected %d\n, + s, i + 1); + } + } + + assert(r != false); + } + + if (ck_ring_size(ring) != (unsigned int)size) { + ck_error(Less entries than expected: %u %d\n, + ck_ring_size(ring), size); + } + + if (ck_ring_capacity(ring) != ck_ring_size(ring) + 1) { + ck_error(Capacity less than expected: %u %u\n, + ck_ring_size(ring), ck_ring_capacity(ring)); + } + } + + ck_barrier_centralized(barrier, sense, nthr); + + for (i = 0; i ITERATIONS; i++) { + for (j = 0; j size; j++) { + buffer = _context[context-previous].buffer; + while (ck_ring_dequeue_spsc(ring + context-previous, + buffer, entry) == false); + + if (context-previous != (unsigned int)entry-tid) { + ck_error([%u:%p] %u != %u\n, +
[10/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/include/gcc/x86/ck_f_pr.h -- diff --git a/lib/ck/include/gcc/x86/ck_f_pr.h b/lib/ck/include/gcc/x86/ck_f_pr.h new file mode 100644 index 000..f82c66b --- /dev/null +++ b/lib/ck/include/gcc/x86/ck_f_pr.h @@ -0,0 +1,152 @@ +/* DO NOT EDIT. This is auto-generated from feature.sh */ +#define CK_F_PR_ADD_16 +#define CK_F_PR_ADD_32 +#define CK_F_PR_ADD_8 +#define CK_F_PR_ADD_CHAR +#define CK_F_PR_ADD_INT +#define CK_F_PR_ADD_PTR +#define CK_F_PR_ADD_UINT +#define CK_F_PR_AND_16 +#define CK_F_PR_AND_32 +#define CK_F_PR_AND_8 +#define CK_F_PR_AND_CHAR +#define CK_F_PR_AND_INT +#define CK_F_PR_AND_PTR +#define CK_F_PR_AND_UINT +#define CK_F_PR_BTC_16 +#define CK_F_PR_BTC_32 +#define CK_F_PR_BTC_INT +#define CK_F_PR_BTC_PTR +#define CK_F_PR_BTC_UINT +#define CK_F_PR_BTR_16 +#define CK_F_PR_BTR_32 +#define CK_F_PR_BTR_INT +#define CK_F_PR_BTR_PTR +#define CK_F_PR_BTR_UINT +#define CK_F_PR_BTS_16 +#define CK_F_PR_BTS_32 +#define CK_F_PR_BTS_INT +#define CK_F_PR_BTS_PTR +#define CK_F_PR_BTS_UINT +#define CK_F_PR_CAS_16 +#define CK_F_PR_CAS_16_VALUE +#define CK_F_PR_CAS_32 +#define CK_F_PR_CAS_32_VALUE +#define CK_F_PR_CAS_8 +#define CK_F_PR_CAS_8_VALUE +#define CK_F_PR_CAS_CHAR +#define CK_F_PR_CAS_CHAR_VALUE +#define CK_F_PR_CAS_INT +#define CK_F_PR_CAS_INT_VALUE +#define CK_F_PR_CAS_PTR +#define CK_F_PR_CAS_PTR_VALUE +#define CK_F_PR_CAS_UINT +#define CK_F_PR_CAS_UINT_VALUE +#define CK_F_PR_DEC_16 +#define CK_F_PR_DEC_16_ZERO +#define CK_F_PR_DEC_32 +#define CK_F_PR_DEC_32_ZERO +#define CK_F_PR_DEC_8 +#define CK_F_PR_DEC_8_ZERO +#define CK_F_PR_DEC_CHAR +#define CK_F_PR_DEC_CHAR_ZERO +#define CK_F_PR_DEC_INT +#define CK_F_PR_DEC_INT_ZERO +#define CK_F_PR_DEC_PTR +#define CK_F_PR_DEC_PTR_ZERO +#define CK_F_PR_DEC_UINT +#define CK_F_PR_DEC_UINT_ZERO +#define CK_F_PR_FAA_16 +#define CK_F_PR_FAA_32 +#define CK_F_PR_FAA_8 +#define CK_F_PR_FAA_CHAR +#define CK_F_PR_FAA_INT +#define CK_F_PR_FAA_PTR +#define CK_F_PR_FAA_UINT +#define CK_F_PR_FAS_16 +#define CK_F_PR_FAS_32 +#define CK_F_PR_FAS_8 +#define CK_F_PR_FAS_CHAR +#define CK_F_PR_FAS_INT +#define CK_F_PR_FAS_PTR +#define CK_F_PR_FAS_UINT +#define CK_F_PR_FENCE_LOAD +#define CK_F_PR_FENCE_LOAD_DEPENDS +#define CK_F_PR_FENCE_MEMORY +#define CK_F_PR_FENCE_STORE +#define CK_F_PR_FENCE_STRICT_LOAD +#define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS +#define CK_F_PR_FENCE_STRICT_MEMORY +#define CK_F_PR_FENCE_STRICT_STORE +#define CK_F_PR_INC_16 +#define CK_F_PR_INC_16_ZERO +#define CK_F_PR_INC_32 +#define CK_F_PR_INC_32_ZERO +#define CK_F_PR_INC_8 +#define CK_F_PR_INC_8_ZERO +#define CK_F_PR_INC_CHAR +#define CK_F_PR_INC_CHAR_ZERO +#define CK_F_PR_INC_INT +#define CK_F_PR_INC_INT_ZERO +#define CK_F_PR_INC_PTR +#define CK_F_PR_INC_PTR_ZERO +#define CK_F_PR_INC_UINT +#define CK_F_PR_INC_UINT_ZERO +#define CK_F_PR_LOAD_16 +#define CK_F_PR_LOAD_32 +#define CK_F_PR_LOAD_8 +#define CK_F_PR_LOAD_CHAR +#define CK_F_PR_LOAD_INT +#define CK_F_PR_LOAD_PTR +#define CK_F_PR_LOAD_UINT +#define CK_F_PR_NEG_16 +#define CK_F_PR_NEG_16_ZERO +#define CK_F_PR_NEG_32 +#define CK_F_PR_NEG_32_ZERO +#define CK_F_PR_NEG_8 +#define CK_F_PR_NEG_8_ZERO +#define CK_F_PR_NEG_CHAR +#define CK_F_PR_NEG_CHAR_ZERO +#define CK_F_PR_NEG_INT +#define CK_F_PR_NEG_INT_ZERO +#define CK_F_PR_NEG_PTR +#define CK_F_PR_NEG_PTR_ZERO +#define CK_F_PR_NEG_UINT +#define CK_F_PR_NEG_UINT_ZERO +#define CK_F_PR_NOT_16 +#define CK_F_PR_NOT_32 +#define CK_F_PR_NOT_8 +#define CK_F_PR_NOT_CHAR +#define CK_F_PR_NOT_INT +#define CK_F_PR_NOT_PTR +#define CK_F_PR_NOT_UINT +#define CK_F_PR_OR_16 +#define CK_F_PR_OR_32 +#define CK_F_PR_OR_8 +#define CK_F_PR_OR_CHAR +#define CK_F_PR_OR_INT +#define CK_F_PR_OR_PTR +#define CK_F_PR_OR_UINT +#define CK_F_PR_STALL +#define CK_F_PR_STORE_16 +#define CK_F_PR_STORE_32 +#define CK_F_PR_STORE_8 +#define CK_F_PR_STORE_CHAR +#define CK_F_PR_STORE_INT +#define CK_F_PR_STORE_PTR +#define CK_F_PR_STORE_UINT +#define CK_F_PR_SUB_16 +#define CK_F_PR_SUB_32 +#define CK_F_PR_SUB_8 +#define CK_F_PR_SUB_CHAR +#define CK_F_PR_SUB_INT +#define CK_F_PR_SUB_PTR +#define CK_F_PR_SUB_UINT +#define CK_F_PR_XOR_16 +#define CK_F_PR_XOR_32 +#define CK_F_PR_XOR_8 +#define CK_F_PR_XOR_CHAR +#define CK_F_PR_XOR_INT +#define CK_F_PR_XOR_PTR +#define CK_F_PR_XOR_UINT + http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/include/gcc/x86/ck_pr.h -- diff --git a/lib/ck/include/gcc/x86/ck_pr.h b/lib/ck/include/gcc/x86/ck_pr.h new file mode 100644 index 000..2ed3e38 --- /dev/null +++ b/lib/ck/include/gcc/x86/ck_pr.h @@ -0,0 +1,388 @@ +/* + * Copyright 2009-2014 Samy Al Bahra. + * Copyright 2011 Devon H. O'Dell devon.od...@gmail.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following
[18/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_brlock -- diff --git a/lib/ck/doc/ck_brlock b/lib/ck/doc/ck_brlock new file mode 100644 index 000..7972ee4 --- /dev/null +++ b/lib/ck/doc/ck_brlock @@ -0,0 +1,121 @@ +.\ +.\ Copyright 2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd July 26, 2013. +.Dt ck_brlock 3 +.Sh NAME +.Nm ck_brlock_init , +.Nm ck_brlock_write_lock , +.Nm ck_brlock_write_unlock , +.Nm ck_brlock_write_trylock , +.Nm ck_brlock_read_register , +.Nm ck_brlock_read_unregister , +.Nm ck_brlock_read_lock , +.Nm ck_brlock_read_trylock , +.Nm ck_brlock_read_unlock +.Nd big-reader locks +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_brlock.h +.Pp +.Dv ck_brlock_t brlock = CK_BRLOCK_INITIALIZER; +.Pp +.Dv ck_brlock_reader_t reader = CK_BRLOCK_READER_INITIALIZER; +.Pp +.Ft void +.Fn ck_brlock_init ck_brlock_t *br +.Ft void +.Fn ck_brlock_write_lock ck_brlock_t *br +.Ft void +.Fn ck_brlock_write_unlock ck_brlock_t *br +.Ft bool +.Fn ck_brlock_write_trylock ck_brlock_t *br unsigned int factor +.Ft void +.Fn ck_brlock_read_register ck_brlock_t *br ck_brlock_reader_t *reader +.Ft void +.Fn ck_brlock_read_unregister ck_brlock_t *br ck_brlock_reader_t *reader +.Ft void +.Fn ck_brlock_read_lock ck_brlock_t *br ck_brlock_reader_t *reader +.Ft bool +.Fn ck_brlock_read_trylock ck_brlock_t *br ck_brlock_reader_t *reader \ +unsigned int factor +.Ft void +.Fn ck_brlock_read_unlock ck_brlock_reader_t *reader +.Sh DESCRIPTION +Big reader locks are distributed reader-writer locks with low latency constant time +reader acquisition (with respect to number of concurrent readers). On the other +hand, writer acquisitions are a relatively expensive O(n) operation. This is a write-biased +lock. +.Sh EXAMPLE +.Bd -literal -offset indent +static ck_brlock_t lock = CK_BRLOCK_INITIALIZER; +static __thread ck_brlock_reader_t reader; + +static void +reader(void) +{ + + /* Add our thread as a lock participant. */ + ck_brlock_read_register(lock, reader); + + for (;;) { + ck_brlock_read_lock(lock, reader); + /* Read-side critical section. */ + ck_brlock_read_unlock(reader); + + if (ck_brlock_read_trylock(lock, reader, 1) == true) { + /* Read-side critical section. */ + ck_brlock_read_unlock(reader); + } + } + + return; +} + +static void +writer(void) +{ + + for (;;) { + ck_brlock_write_lock(lock); + /* Write-side critical section. */ + ck_brlock_write_unlock(lock); + + if (ck_brlock_write_trylock(lock, 1) == true) { + /* Write-side critical section. */ + ck_brlock_write_unlock(lock); + } + } + + return; +} +.Ed +.Sh SEE ALSO +.Xr ck_bytelock 3 , +.Xr ck_rwlock 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_cohort -- diff --git a/lib/ck/doc/ck_cohort b/lib/ck/doc/ck_cohort new file mode 100644 index 000..b033c91 --- /dev/null +++ b/lib/ck/doc/ck_cohort @@ -0,0 +1,211 @@ +.\ +.\ Copyright 2013 Brendon Scheinman. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\
[05/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/regressions/ck_pr/validate/ck_pr_unary.c -- diff --git a/lib/ck/regressions/ck_pr/validate/ck_pr_unary.c b/lib/ck/regressions/ck_pr/validate/ck_pr_unary.c new file mode 100644 index 000..b2300cd --- /dev/null +++ b/lib/ck/regressions/ck_pr/validate/ck_pr_unary.c @@ -0,0 +1,117 @@ +/* + * Copyright 2011 David Joseph. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include stdio.h +#include stdlib.h +#include unistd.h +#include ck_pr.h + +#define REPEAT 200 + +#define TEST_UNARY(K, S, M, T, P, D, H) \ + static void \ + test_##K##_##S(M *target) \ + { \ + *target = *target P 1; \ + \ + return; \ + } \ + static void \ + test_##K##_##S##_zero(M *target, bool *zero) \ + { \ + *zero = *target == H; \ + *target = *target P 1; \ + \ + return; \ + } \ + static void \ + run_test_##K##_##S(bool use_zero) \ + { \ + int i; \ + T x = 1, y = 1; \ + bool zero_x = false, zero_y = false; \ + \ + use_zero ? puts(***TESTING ck_pr_#K_#S_zero***) \ +: puts(***TESTING ck_pr_#K_#S***); \ + for (i = 0; i REPEAT; ++i) { \ + if (use_zero) { \ + test_##K##_##S##_zero(x, zero_x); \ + ck_pr_##K##_##S##_zero(y, zero_y);
[14/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_ring_enqueue_spmc -- diff --git a/lib/ck/doc/ck_ring_enqueue_spmc b/lib/ck/doc/ck_ring_enqueue_spmc new file mode 100644 index 000..20fd6a8 --- /dev/null +++ b/lib/ck/doc/ck_ring_enqueue_spmc @@ -0,0 +1,115 @@ +.\ +.\ Copyright 2012-2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd April 20, 2013 +.Dt CK_RING_ENQUEUE_SPMC 3 +.Sh NAME +.Nm ck_ring_enqueue_spmc +.Nd enqueue pointer into bounded FIFO +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_ring.h +.Ft bool +.Fn ck_ring_enqueue_spmc ck_ring_t *ring ck_ring_buffer_t *buffer void *entry +.Sh DESCRIPTION +The +.Fn ck_ring_enqueue_spmc 3 +function enqueues the pointer +.Fa entry +into the bounded buffer pointed to by +.Fa ring +in FIFO fashion. +The buffer pointed to by +.Fa buffer +must be unique to +.Fa ring +and point to an array of ck_ring_buffer_t of sufficient +length (according to the power-of-2 elements in the buffer). +The decoupling of the ring from the buffer serves +to address use-cases involving multiple address spaces +and DMA, among others. +If you are on non-POSIX platforms or wish for strict +compliance with C, then it is recommended to pass a +pointer of type void ** for +.Fa entry . +This function is safe to call without locking for UINT_MAX +concurrent invocations of +.Fn ck_ring_dequeue_spmc 3 +or +.Fn ck_ring_trydequeue_spmc 3 . +This function provides wait-free progress +guarantees for one active invocation. +.Sh EXAMPLE +.Bd -literal -offset indent +#include ck_ring.h + +/* This ring was previously initialized with ck_ring_init. */ +ck_ring_t ring; + +/* The ring was initialized for 1023 elements. */ +ck_ring_buffer_t buffer[1024]; + +void +enqueue(void) +{ + void *entry = some_object; + + /* Attempt to enqueue pointer to some_object into buffer. */ + if (ck_ring_enqueue_spmc(ring, buffer, entry) == false) { + /* +* The buffer was full and the enqueue operation +* has failed. +*/ + return; + } + + /* Enqueue operation completed successfully. */ + return; +} +.Ed +.Sh RETURN VALUES +The function returns true if the value of +.Fa entry +was successfully enqueued into +.Fa ring . +The function will return false if the value of +.Fa entry +could not be enqueued which only occurs if +.Fa ring +was full. +.Sh SEE ALSO +.Xr ck_ring_init 3 , +.Xr ck_ring_dequeue_spmc 3 , +.Xr ck_ring_trydequeue_spmc 3 , +.Xr ck_ring_enqueue_spmc_size 3 , +.Xr ck_ring_dequeue_spsc 3 , +.Xr ck_ring_enqueue_spsc 3 , +.Xr ck_ring_enqueue_spsc_size 3 , +.Xr ck_ring_capacity 3 , +.Xr ck_ring_size 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_ring_enqueue_spmc_size -- diff --git a/lib/ck/doc/ck_ring_enqueue_spmc_size b/lib/ck/doc/ck_ring_enqueue_spmc_size new file mode 100644 index 000..900bd28 --- /dev/null +++ b/lib/ck/doc/ck_ring_enqueue_spmc_size @@ -0,0 +1,127 @@ +.\ +.\ Copyright 2012-2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\
[17/20] TS-2950: Initial commit of libck.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_hs_next -- diff --git a/lib/ck/doc/ck_hs_next b/lib/ck/doc/ck_hs_next new file mode 100644 index 000..1e41301 --- /dev/null +++ b/lib/ck/doc/ck_hs_next @@ -0,0 +1,92 @@ +.\ +.\ Copyright 2012-2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd September 17, 2012 +.Dt CK_HS_NEXT 3 +.Sh NAME +.Nm ck_hs_next +.Nd iterate to next entry in hash set +.Sh LIBRARY +Concurrency Kit (libck, \-lck) +.Sh SYNOPSIS +.In ck_hs.h +.Ft bool +.Fn ck_hs_next ck_hs_t *hs ck_hs_iterator_t *iterator void **entry +.Sh DESCRIPTION +The +.Fn ck_hs_next 3 +function will increment the iterator object pointed to by +.Fa iterator +to point to the next non-empty hash set entry. If +.Fn ck_hs_next 3 +returns true then the pointer pointed to by +.Fa entry +is initialized to the current hash set key pointed to by the +.Fa iterator +object. +.Pp +It is expected that +.Fa iterator +has been initialized using the +.Xr ck_hs_iterator_init 3 +function or statically initialized using CK_HS_ITERATOR_INITIALIZER. +.Sh RETURN VALUES +If +.Fn ck_hs_next 3 +returns true then the object pointed to by +.Fa entry +points to a valid hash set key. If +.Fn ck_hs_next 3 +returns false then the value of the object pointed to by +.Fa entry +is undefined. +.Sh ERRORS +Behavior is undefined if +.Fa iterator +or +.Fa hs +are uninitialized. +.Sh SEE ALSO +.Xr ck_hs_init 3 , +.Xr ck_hs_move 3 , +.Xr ck_hs_destroy 3 , +.Xr CK_HS_HASH 3 , +.Xr ck_hs_iterator_init 3 , +.Xr ck_hs_get 3 , +.Xr ck_hs_put 3 , +.Xr ck_hs_put_unique 3 , +.Xr ck_hs_set 3 , +.Xr ck_hs_fas 3 , +.Xr ck_hs_remove 3 , +.Xr ck_hs_grow 3 , +.Xr ck_hs_rebuild 3 , +.Xr ck_hs_gc 3 , +.Xr ck_hs_count 3 , +.Xr ck_hs_reset 3 , +.Xr ck_hs_reset_size 3 , +.Xr ck_hs_stat 3 +.Pp +Additional information available at http://concurrencykit.org/ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/f098175e/lib/ck/doc/ck_hs_put -- diff --git a/lib/ck/doc/ck_hs_put b/lib/ck/doc/ck_hs_put new file mode 100644 index 000..8f8f55f --- /dev/null +++ b/lib/ck/doc/ck_hs_put @@ -0,0 +1,98 @@ +.\ +.\ Copyright 2012-2013 Samy Al Bahra. +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with or without +.\ modification, are permitted provided that the following conditions +.\ are met: +.\ 1. Redistributions of source code must retain the above copyright +.\notice, this list of conditions and the following disclaimer. +.\ 2. Redistributions in binary form must reproduce the above copyright +.\notice, this list of conditions and the following disclaimer in the +.\documentation and/or other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\ SUCH DAMAGE. +.\ +.\ +.Dd September 17, 2012 +.Dt CK_HS_PUT 3 +.Sh NAME
[5/9] git commit: TS-2977: minimize web2 and cluster in the headers search path
TS-2977: minimize web2 and cluster in the headers search path Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ff716f21 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ff716f21 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ff716f21 Branch: refs/heads/master Commit: ff716f219a86284fb980ba2ed05c41105ce274ef Parents: 1bba62b Author: James Peach jpe...@apache.org Authored: Thu Jul 31 13:48:17 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:45 2014 -0700 -- cmd/traffic_manager/Main.cc | 7 +++ cmd/traffic_manager/StatProcessor.cc | 2 +- lib/records/Makefile.am | 2 -- mgmt/Alarms.cc | 2 +- mgmt/LocalManager.cc | 14 ++ mgmt/LocalManager.h | 17 +++-- mgmt/api/CoreAPI.cc | 3 ++- mgmt/cluster/ClusterCom.cc | 1 + mgmt/cluster/Makefile.am | 1 - mgmt/cluster/VMap.cc | 1 + mgmt/utils/Makefile.am | 2 -- mgmt/web2/WebOverview.cc | 2 +- proxy/shared/Makefile.am | 2 -- 13 files changed, 27 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/cmd/traffic_manager/Main.cc -- diff --git a/cmd/traffic_manager/Main.cc b/cmd/traffic_manager/Main.cc index d54eb94..8d80a24 100644 --- a/cmd/traffic_manager/Main.cc +++ b/cmd/traffic_manager/Main.cc @@ -21,8 +21,7 @@ limitations under the License. */ -#include ink_config.h -#include ink_platform.h +#include libts.h #include ink_sys_control.h #include Main.h @@ -30,11 +29,11 @@ #include WebMgmtUtils.h #include WebIntrMain.h #include WebOverview.h +#include ClusterCom.h +#include VMap.h #include FileManager.h #include I_Layout.h #include I_Version.h -#include ink_syslog.h -#include ink_lockfile.h #include Diags.h #include DiagsConfig.h #include URL.h http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/cmd/traffic_manager/StatProcessor.cc -- diff --git a/cmd/traffic_manager/StatProcessor.cc b/cmd/traffic_manager/StatProcessor.cc index 24cbaa9..3fd670e 100644 --- a/cmd/traffic_manager/StatProcessor.cc +++ b/cmd/traffic_manager/StatProcessor.cc @@ -30,7 +30,7 @@ * / -#include ink_config.h +#include libts.h #include StatProcessor.h #include FileManager.h http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/lib/records/Makefile.am -- diff --git a/lib/records/Makefile.am b/lib/records/Makefile.am index 744194c..e3b74cf 100644 --- a/lib/records/Makefile.am +++ b/lib/records/Makefile.am @@ -20,8 +20,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/iocore/eventsystem \ -I$(top_srcdir)/iocore/utils \ -I$(top_srcdir)/mgmt \ - -I$(top_srcdir)/mgmt/cluster \ - -I$(top_srcdir)/mgmt/web2 \ -I$(top_srcdir)/mgmt/api/include \ -I$(top_srcdir)/mgmt/utils \ -I$(top_srcdir)/lib \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/mgmt/Alarms.cc -- diff --git a/mgmt/Alarms.cc b/mgmt/Alarms.cc index b44930f..aed1537 100644 --- a/mgmt/Alarms.cc +++ b/mgmt/Alarms.cc @@ -24,11 +24,11 @@ #include libts.h #include LocalManager.h +#include ClusterCom.h #include MgmtUtils.h #include Alarms.h #include Diags.h - #include P_RecCore.h const char *alarmText[] = { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/mgmt/LocalManager.cc -- diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc index d6930e1..885b054 100644 --- a/mgmt/LocalManager.cc +++ b/mgmt/LocalManager.cc @@ -31,6 +31,8 @@ #include MgmtSocket.h #include ink_cap.h #include FileManager.h +#include ClusterCom.h +#include VMap.h #if TS_USE_POSIX_CAP #include sys/capability.h @@ -290,6 +292,18 @@ LocalManager::LocalManager(bool proxy_on) return; } +LocalManager::~LocalManager() +{ + delete alarm_keeper; + delete virt_map; + delete ccom; + ats_free(absolute_proxy_binary); + ats_free(proxy_name); + ats_free(proxy_binary); + ats_free(proxy_options); + ats_free(env_prep); +} + void LocalManager::initAlarm() { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ff716f21/mgmt/LocalManager.h -- diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h index 785cbc0..a001646 100644 ---
[8/9] git commit: TS-2977: incorporate libutils into libmgmt
TS-2977: incorporate libutils into libmgmt Simplify the link topology by incorporating libutils into libmgmt. Management clients don't need to know the gory details. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1bba62b6 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1bba62b6 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1bba62b6 Branch: refs/heads/master Commit: 1bba62b68cad0cfb5bba8d6d4c1b735f80408e88 Parents: 9e6d233 Author: James Peach jpe...@apache.org Authored: Thu Jul 31 13:27:50 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:45 2014 -0700 -- cmd/traffic_manager/Makefile.am | 4 +--- iocore/aio/Makefile.am | 3 +-- iocore/eventsystem/Makefile.am | 5 ++--- mgmt/Makefile.am| 27 --- mgmt/cluster/Makefile.am| 4 ++-- mgmt/utils/Makefile.am | 6 +++--- proxy/Makefile.am | 15 +-- 7 files changed, 30 insertions(+), 34 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1bba62b6/cmd/traffic_manager/Makefile.am -- diff --git a/cmd/traffic_manager/Makefile.am b/cmd/traffic_manager/Makefile.am index e547f1d..6ba9bfd 100644 --- a/cmd/traffic_manager/Makefile.am +++ b/cmd/traffic_manager/Makefile.am @@ -45,12 +45,10 @@ traffic_manager_SOURCES = \ traffic_manager_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @EXPAT_LDFLAGS@ @LIBTOOL_LINK_FLAGS@ traffic_manager_LDADD = \ - $(top_builddir)/mgmt/libmgmt_lm.a \ - $(top_builddir)/mgmt/cluster/libcluster.a \ + $(top_builddir)/mgmt/libmgmt_lm.la \ $(top_builddir)/mgmt/web2/libweb.a \ $(top_builddir)/mgmt/api/libmgmtapilocal.a \ $(top_builddir)/mgmt/api/libtsmgmtshare.la \ - $(top_builddir)/mgmt/utils/libutils_lm.a \ $(top_builddir)/proxy/hdrs/libhdrs.a \ $(top_builddir)/lib/records/librecords_lm.a \ $(top_builddir)/lib/ts/libtsutil.la \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1bba62b6/iocore/aio/Makefile.am -- diff --git a/iocore/aio/Makefile.am b/iocore/aio/Makefile.am index 51adaa2..6972946 100644 --- a/iocore/aio/Makefile.am +++ b/iocore/aio/Makefile.am @@ -51,8 +51,7 @@ test_AIO_CXXFLAGS = \ test_AIO_LDADD = \ libinkaio.a \ $(top_builddir)/lib/records/librecords_p.a \ - $(top_builddir)/mgmt/libmgmt_p.a \ - $(top_builddir)/mgmt/utils/libutils_p.a \ + $(top_builddir)/mgmt/libmgmt_p.la \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/lib/ts/libtsutil.la \ $(top_builddir)/proxy/shared/libUglyLogStubs.a \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1bba62b6/iocore/eventsystem/Makefile.am -- diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am index ce1a432..ba01782 100644 --- a/iocore/eventsystem/Makefile.am +++ b/iocore/eventsystem/Makefile.am @@ -67,7 +67,7 @@ libinkevent_a_SOURCES = \ Thread.cc \ UnixEThread.cc \ UnixEvent.cc \ - UnixEventProcessor.cc + UnixEventProcessor.cc check_PROGRAMS = test_Buffer test_Event @@ -85,8 +85,7 @@ test_CXXFLAGS = \ test_LDADD = \ libinkevent.a \ $(top_builddir)/lib/records/librecords_p.a \ - $(top_builddir)/mgmt/libmgmt_p.a \ - $(top_builddir)/mgmt/utils/libutils_p.a \ + $(top_builddir)/mgmt/libmgmt_p.la \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/lib/ts/libtsutil.la \ $(top_builddir)/proxy/shared/libUglyLogStubs.a \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1bba62b6/mgmt/Makefile.am -- diff --git a/mgmt/Makefile.am b/mgmt/Makefile.am index e76f70d..ce477e1 100644 --- a/mgmt/Makefile.am +++ b/mgmt/Makefile.am @@ -19,7 +19,7 @@ SUBDIRS = cluster utils web2 api -noinst_LIBRARIES = libmgmt_p.a libmgmt_lm.a +noinst_LTLIBRARIES = libmgmt_p.la libmgmt_lm.la AM_CPPFLAGS = \ $(iocore_include_dirs) \ @@ -35,31 +35,36 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib -libmgmt_p_a_SOURCES = \ +libmgmt_COMMON = \ BaseManager.cc \ BaseManager.h \ MgmtDefs.h \ + RecordsConfig.cc \ + RecordsConfig.h + +libmgmt_p_la_SOURCES = \ + $(libmgmt_COMMON) \ ProcessManager.cc \ ProcessManager.h \ ProxyConfig.cc \ - ProxyConfig.h \ - RecordsConfig.cc \ - RecordsConfig.h + ProxyConfig.h -libmgmt_lm_a_SOURCES = \ +libmgmt_lm_la_SOURCES = \ + $(libmgmt_COMMON) \ Alarms.cc \ Alarms.h \ - BaseManager.cc \ - BaseManager.h \ FileManager.cc \ FileManager.h \ LocalManager.cc \ LocalManager.h \ - MgmtDefs.h \ MultiFile.cc
[2/9] git commit: TS-2977: move traffic_manager
TS-2977: move traffic_manager Move traffic_manager to the cmd subdirectory. The local manager implementation is tightly coupled to traffic_manager, so break that as much as we can by passing globals down. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/93f46af2 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/93f46af2 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/93f46af2 Branch: refs/heads/master Commit: 93f46af23d40c0bc0ae369523212165590d587d3 Parents: f098175 Author: James Peach jpe...@apache.org Authored: Wed Jul 30 14:36:28 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:44 2014 -0700 -- .gitignore|2 +- cmd/Makefile.am |6 +- cmd/traffic_manager/AddConfigFilesHere.cc | 89 ++ cmd/traffic_manager/Main.cc | 1199 +++ cmd/traffic_manager/Main.h| 53 ++ cmd/traffic_manager/Makefile.am | 67 ++ configure.ac |1 + lib/records/I_RecLocal.h |4 +- lib/records/RecLocal.cc | 17 +- mgmt/AddConfigFilesHere.cc| 89 -- mgmt/Alarms.cc|4 +- mgmt/Alarms.h |3 +- mgmt/FileManager.cc |1 + mgmt/LocalManager.cc | 14 +- mgmt/LocalManager.h |9 +- mgmt/Main.cc | 1214 mgmt/Main.h | 53 -- mgmt/Makefile.am | 55 +- mgmt/Rollback.cc |5 +- mgmt/Rollback.h |4 + mgmt/api/CoreAPI.cc |3 +- mgmt/api/TSControlMain.cc |1 - mgmt/cluster/ClusterCom.cc| 91 +- mgmt/cluster/ClusterCom.h | 12 +- mgmt/cluster/VMap.cc |3 +- mgmt/cluster/VMap.h |2 + mgmt/stats/StatProcessor.cc |7 +- mgmt/stats/StatProcessor.h|4 +- mgmt/utils/WebMgmtUtils.cc|1 + mgmt/web2/WebHttpMessage.cc |3 +- 30 files changed, 1523 insertions(+), 1493 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/93f46af2/.gitignore -- diff --git a/.gitignore b/.gitignore index 60de08e..1dd1b3e 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ cmd/traffic_line/traffic_line cmd/traffic_shell/traffic_shell cmd/traffic_cop/traffic_cop cmd/traffic_top/traffic_top +cmd/traffic_manager/traffic_manager lib/ts/ink_autoconf.h lib/ts/ink_config.h @@ -86,7 +87,6 @@ mgmt/tools/traffic_time_config mgmt/tools/traffic_vip_config mgmt/api/api_cli_remote mgmt/tools/shmem_clean -mgmt/traffic_manager proxy/traffic_logcat proxy/traffic_logstats proxy/traffic_sac http://git-wip-us.apache.org/repos/asf/trafficserver/blob/93f46af2/cmd/Makefile.am -- diff --git a/cmd/Makefile.am b/cmd/Makefile.am index 58a8a68..ad51e76 100644 --- a/cmd/Makefile.am +++ b/cmd/Makefile.am @@ -15,4 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -SUBDIRS = traffic_top traffic_cop traffic_line +SUBDIRS = \ + traffic_cop \ + traffic_line \ + traffic_manager \ + traffic_top http://git-wip-us.apache.org/repos/asf/trafficserver/blob/93f46af2/cmd/traffic_manager/AddConfigFilesHere.cc -- diff --git a/cmd/traffic_manager/AddConfigFilesHere.cc b/cmd/traffic_manager/AddConfigFilesHere.cc new file mode 100644 index 000..cc6d169 --- /dev/null +++ b/cmd/traffic_manager/AddConfigFilesHere.cc @@ -0,0 +1,89 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an AS IS BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the
[7/9] git commit: TS-2977: move the stats processor to traffic_manager
TS-2977: move the stats processor to traffic_manager Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9e6d233f Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9e6d233f Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9e6d233f Branch: refs/heads/master Commit: 9e6d233fe647863adb7b093cd6643739f73c7c8e Parents: 7386583 Author: James Peach jpe...@apache.org Authored: Thu Jul 31 10:53:44 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:45 2014 -0700 -- cmd/traffic_manager/Makefile.am | 10 +- cmd/traffic_manager/StatProcessor.cc | 359 + cmd/traffic_manager/StatProcessor.h | 94 +++ cmd/traffic_manager/StatType.cc | 1199 + cmd/traffic_manager/StatType.h | 231 ++ cmd/traffic_manager/StatXML.cc | 82 ++ cmd/traffic_manager/StatXML.h| 47 ++ cmd/traffic_manager/stats.txt| 236 ++ configure.ac |1 - mgmt/Makefile.am |2 +- mgmt/stats/Makefile.am | 40 - mgmt/stats/StatProcessor.cc | 359 - mgmt/stats/StatProcessor.h | 94 --- mgmt/stats/StatType.cc | 1199 - mgmt/stats/StatType.h| 231 -- mgmt/stats/StatXML.cc| 82 -- mgmt/stats/StatXML.h | 47 -- mgmt/stats/spec | 236 -- 18 files changed, 2256 insertions(+), 2293 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e6d233f/cmd/traffic_manager/Makefile.am -- diff --git a/cmd/traffic_manager/Makefile.am b/cmd/traffic_manager/Makefile.am index 1bb5614..e547f1d 100644 --- a/cmd/traffic_manager/Makefile.am +++ b/cmd/traffic_manager/Makefile.am @@ -27,7 +27,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/mgmt \ -I$(top_srcdir)/mgmt/api/include \ -I$(top_srcdir)/mgmt/cluster \ - -I$(top_srcdir)/mgmt/stats \ -I$(top_srcdir)/mgmt/utils \ -I$(top_srcdir)/mgmt/web2 \ -I$(top_srcdir)/lib \ @@ -36,13 +35,18 @@ AM_CPPFLAGS = \ traffic_manager_SOURCES = \ AddConfigFilesHere.cc \ Main.cc \ - Main.h + Main.h \ + StatProcessor.cc \ + StatProcessor.h \ + StatType.cc \ + StatType.h \ + StatXML.cc \ + StatXML.h traffic_manager_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @EXPAT_LDFLAGS@ @LIBTOOL_LINK_FLAGS@ traffic_manager_LDADD = \ $(top_builddir)/mgmt/libmgmt_lm.a \ $(top_builddir)/mgmt/cluster/libcluster.a \ - $(top_builddir)/mgmt/stats/libstats.a \ $(top_builddir)/mgmt/web2/libweb.a \ $(top_builddir)/mgmt/api/libmgmtapilocal.a \ $(top_builddir)/mgmt/api/libtsmgmtshare.la \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e6d233f/cmd/traffic_manager/StatProcessor.cc -- diff --git a/cmd/traffic_manager/StatProcessor.cc b/cmd/traffic_manager/StatProcessor.cc new file mode 100644 index 000..24cbaa9 --- /dev/null +++ b/cmd/traffic_manager/StatProcessor.cc @@ -0,0 +1,359 @@ +/** @file + + A brief file description + + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + License); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an AS IS BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +/***/ +/ + * + * StatProcessor.cc - Functions for computing node and cluster stat + * aggregation + * + * + / + +#include ink_config.h +#include StatProcessor.h +#include FileManager.h + +#define STAT_CONFIG_FILE stats.config.xml + +StatObjectList statObjectList; +StatXMLTag currentTag = INVALID_TAG; +StatObject *statObject = NULL; +char *exprContent = NULL; +static unsigned statCount = 0; // global statistics object counter +bool nodeVar; +bool sumClusterVar; + +// These helpers are used to work around the unsigned char'iness of xmlchar when +//
[9/9] git commit: TS-2977: CHANGES
TS-2977: CHANGES Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/c936bc51 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/c936bc51 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/c936bc51 Branch: refs/heads/master Commit: c936bc514500173bd2075888062eb8618899947e Parents: ab8c0cd Author: James Peach jpe...@apache.org Authored: Fri Aug 1 19:58:54 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:58:54 2014 -0700 -- CHANGES | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c936bc51/CHANGES -- diff --git a/CHANGES b/CHANGES index 02b7f60..68141cc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.1.0 + *) [TS-2977] Move traffic_manager under the cmd subdirectory. + *) [TS-2971] Authproxy plugin has inconsistent debug symbol. *) [TS-2976] Perform some librecords build cleanup.
[6/9] TS-2977: move the stats processor to traffic_manager
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9e6d233f/mgmt/stats/StatType.cc -- diff --git a/mgmt/stats/StatType.cc b/mgmt/stats/StatType.cc deleted file mode 100644 index 1c51b95..000 --- a/mgmt/stats/StatType.cc +++ /dev/null @@ -1,1199 +0,0 @@ -/** @file - - A brief file description - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - License); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an AS IS BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -/***/ -/ - * - * StatType.cc - Functions for computing node and cluster stat - * aggregation - * - * - / - -#include ink_config.h -#include StatType.h -#include MgmtUtils.h -#include ink_hrtime.h -#include WebOverview.h - -bool StatError = false; // global error flag -bool StatDebug = false; // global debug flag - -/** - * StatExprToken() - * --- - */ -StatExprToken::StatExprToken() - : m_arith_symbol('\0'), -m_token_name(NULL), -m_token_type(RECD_NULL), -m_sum_var(false), m_node_var(true) -{ - RecDataClear(RECD_NULL, m_token_value); - RecDataClear(RECD_NULL, m_token_value_max); - RecDataClear(RECD_NULL, m_token_value_min); - memset(m_token_value_delta, 0, sizeof(m_token_value_delta)); -} - - -/** - * StatExprToken::copy() - * - - */ -void -StatExprToken::copy(const StatExprToken source) -{ - m_arith_symbol = source.m_arith_symbol; - - if (source.m_token_name != NULL) { -m_token_name = ats_strdup(source.m_token_name); - } - - m_token_type = source.m_token_type; - m_token_value = source.m_token_value; - m_token_value_min = source.m_token_value_min; - m_token_value_max = source.m_token_value_max; - - if (source.m_token_value_delta) { -m_token_value_delta = new StatDataSamples(); -m_token_value_delta-previous_time = source.m_token_value_delta-previous_time; -m_token_value_delta-current_time = source.m_token_value_delta-current_time; -m_token_value_delta-previous_value = source.m_token_value_delta-previous_value; -m_token_value_delta-current_value = source.m_token_value_delta-current_value; - } - - m_node_var = source.m_node_var; - m_sum_var = source.m_sum_var; -} - - -/** - * StatExprToken::assignTokenName() - * - * Assign the token name. If the token is a predefined constant, - * assign the value as well. Also, assign the token type as well. - */ -void -StatExprToken::assignTokenName(const char *name) -{ - - if (isdigit(name[0])) { -// numerical constant -m_token_name = ats_strdup(CONSTANT); -m_token_type = RECD_CONST; - } else { -m_token_name = ats_strdup(name); -assignTokenType(); - } - - switch (m_token_type) { - case RECD_INT: - case RECD_COUNTER: - case RECD_FLOAT: -break; - case RECD_CONST: -// assign pre-defined constant in here -// constant will be stored as RecFloat type. -if (!strcmp(m_token_name, CONSTANT)) { - m_token_value.rec_float = (RecFloat) atof(name); -} else if (!strcmp(m_token_name, $BYTES_TO_MB_SCALE)) { - m_token_value.rec_float = (RecFloat) BYTES_TO_MB_SCALE; -} else if (!strcmp(m_token_name, $MBIT_TO_KBIT_SCALE)) { - m_token_value.rec_float = (RecFloat) MBIT_TO_KBIT_SCALE; -} else if (!strcmp(m_token_name, $SECOND_TO_MILLISECOND_SCALE)) { - m_token_value.rec_float = (RecFloat) SECOND_TO_MILLISECOND_SCALE; -} else if (!strcmp(m_token_name, $PCT_TO_INTPCT_SCALE)) { - m_token_value.rec_float = (RecFloat) PCT_TO_INTPCT_SCALE; -} else if (!strcmp(m_token_name, $HRTIME_SECOND)) { - m_token_value.rec_float = (RecFloat) HRTIME_SECOND; -} else if (!strcmp(m_token_name, $BYTES_TO_MBIT_SCALE)) { - m_token_value.rec_float = (RecFloat) BYTES_TO_MBIT_SCALE; -} else { - mgmt_log(stderr, [StatPro] ERROR: Undefined constant: %s\n, m_token_name); - StatError = true; -} - case RECD_FX: - default: -break; - } -} - - -/** - * assignTokenType() - * - - * Assign the proper token type based on the token name. - * Do some token type
[1/9] TS-2977: move traffic_manager
Repository: trafficserver Updated Branches: refs/heads/master f098175e9 - c936bc514 http://git-wip-us.apache.org/repos/asf/trafficserver/blob/93f46af2/mgmt/Main.cc -- diff --git a/mgmt/Main.cc b/mgmt/Main.cc deleted file mode 100644 index 5f285c5..000 --- a/mgmt/Main.cc +++ /dev/null @@ -1,1214 +0,0 @@ -/** @file - - Entry point to the traffic manager. - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - License); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an AS IS BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#include ink_config.h -#include ink_platform.h -#include ink_sys_control.h - -#include Main.h -#include MgmtUtils.h -#include WebMgmtUtils.h -#include WebIntrMain.h -#include WebOverview.h -#include FileManager.h -#include I_Layout.h -#include I_Version.h -#include ink_syslog.h -#include ink_lockfile.h -#include Diags.h -#include DiagsConfig.h -#include URL.h -#include MIME.h -#include HTTP.h - -// Needs LibRecordsConfigInit() -#include RecordsConfig.h - - - -#include StatProcessor.h -#include P_RecLocal.h -#include P_RecCore.h - -#if TS_USE_POSIX_CAP -#include sys/capability.h -#endif -#include grp.h - -#define FD_THROTTLE_HEADROOM (128 + 64) // TODO: consolidate with THROTTLE_FD_HEADROOM -#define DIAGS_LOG_FILENAME manager.log - -#if defined(freebsd) -extern C int getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, struct passwd **resptr); -#endif - -static void extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *fds_throttle); - -LocalManager *lmgmt = NULL; -FileManager *configFiles; - -StatProcessor *statProcessor; // Statistics Processors -AppVersionInfo appVersionInfo; // Build info for this application - -static inkcoreapi DiagsConfig *diagsConfig; -static char debug_tags[1024] = ; -static char action_tags[1024] = ; -static bool proxy_on = true; - -char mgmt_path[PATH_NAME_MAX + 1]; - -// By default, set the current directory as base -static const char *recs_conf = records.config; - -static int fds_limit; - -// TODO: Use positive instead negative selection -// Thsis should just be #if defined(solaris) -#if !defined(linux) !defined(freebsd) !defined(darwin) -static void SignalHandler(int sig, siginfo_t * t, void *f); -static void SignalAlrmHandler(int sig, siginfo_t * t, void *f); -#else -static void SignalHandler(int sig); -static void SignalAlrmHandler(int sig); -#endif - -static volatile int sigHupNotifier = 0; -static volatile int sigUsr2Notifier = 0; -static void SigChldHandler(int sig); - -static void -check_lockfile() -{ - ats_scoped_str rundir(RecConfigReadRuntimeDir()); - char lockfile[PATH_NAME_MAX]; - int err; - pid_t holding_pid; - - // - // test for presence of server lock // - // - Layout::relative_to(lockfile, sizeof(lockfile), rundir, SERVER_LOCK); - Lockfile server_lockfile(lockfile); - err = server_lockfile.Open(holding_pid); - if (err == 1) { -server_lockfile.Close();// no server running - } else { -char *reason = strerror(-err); -if (err == 0) { - // TODO: Add PID_FMT_T instead duplicating code just for printing -#if defined(solaris) - fprintf(stderr, FATAL: Lockfile '%s' says server already running as PID %d\n, lockfile, (int)holding_pid); -#else - fprintf(stderr, FATAL: Lockfile '%s' says server already running as PID %d\n, lockfile, holding_pid); -#endif - mgmt_elog(stderr, 0, FATAL: Lockfile '%s' says server already running as PID %d\n, lockfile, holding_pid); -} else { - fprintf(stderr, FATAL: Can't open server lockfile '%s' (%s)\n, lockfile, (reason ? reason : Unknown Reason)); - mgmt_elog(stderr, 0, FATAL: Can't open server lockfile '%s' (%s)\n, -lockfile, (reason ? reason : Unknown Reason)); -} -exit(1); - } - - /// - // try to get the exclusive manager lock // - /// - Layout::relative_to(lockfile, sizeof(lockfile), rundir, MANAGER_LOCK); - Lockfile manager_lockfile(lockfile); - err = manager_lockfile.Get(holding_pid); - if (err != 1) { -char *reason = strerror(-err); -fprintf(stderr, FATAL: Can't acquire
[3/9] git commit: TS-2977: rename traffic_manager Main.cc
TS-2977: rename traffic_manager Main.cc Rename traffic_manager's Main.cc to traffic_manager.cc. Remove Main.h, retaining just the 2 or 3 things from it that are used. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ab8c0cd2 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ab8c0cd2 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ab8c0cd2 Branch: refs/heads/master Commit: ab8c0cd21a0ab6e832e969f006ace578661c4d47 Parents: ff716f2 Author: James Peach jpe...@apache.org Authored: Thu Jul 31 14:20:39 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:45 2014 -0700 -- cmd/traffic_manager/AddConfigFilesHere.cc |4 +- cmd/traffic_manager/Main.cc | 1198 --- cmd/traffic_manager/Main.h| 53 -- cmd/traffic_manager/Makefile.am |3 +- cmd/traffic_manager/StatType.h|1 - cmd/traffic_manager/traffic_manager.cc| 1202 6 files changed, 1206 insertions(+), 1255 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ab8c0cd2/cmd/traffic_manager/AddConfigFilesHere.cc -- diff --git a/cmd/traffic_manager/AddConfigFilesHere.cc b/cmd/traffic_manager/AddConfigFilesHere.cc index cc6d169..bfed735 100644 --- a/cmd/traffic_manager/AddConfigFilesHere.cc +++ b/cmd/traffic_manager/AddConfigFilesHere.cc @@ -22,10 +22,12 @@ */ #include ink_platform.h -#include Main.h #include MgmtUtils.h #include ConfigParse.h #include Diags.h +#include FileManager.h + +extern FileManager *configFiles; / * http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ab8c0cd2/cmd/traffic_manager/Main.cc -- diff --git a/cmd/traffic_manager/Main.cc b/cmd/traffic_manager/Main.cc deleted file mode 100644 index 8d80a24..000 --- a/cmd/traffic_manager/Main.cc +++ /dev/null @@ -1,1198 +0,0 @@ -/** @file - - Entry point to the traffic manager. - - @section license License - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - License); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an AS IS BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#include libts.h -#include ink_sys_control.h - -#include Main.h -#include MgmtUtils.h -#include WebMgmtUtils.h -#include WebIntrMain.h -#include WebOverview.h -#include ClusterCom.h -#include VMap.h -#include FileManager.h -#include I_Layout.h -#include I_Version.h -#include Diags.h -#include DiagsConfig.h -#include URL.h -#include MIME.h -#include HTTP.h - -// Needs LibRecordsConfigInit() -#include RecordsConfig.h - -#include StatProcessor.h -#include P_RecLocal.h -#include P_RecCore.h - -#if TS_USE_POSIX_CAP -#include sys/capability.h -#endif -#include grp.h - -#define FD_THROTTLE_HEADROOM (128 + 64) // TODO: consolidate with THROTTLE_FD_HEADROOM -#define DIAGS_LOG_FILENAME manager.log - -#if defined(freebsd) -extern C int getpwnam_r(const char *name, struct passwd *result, char *buffer, size_t buflen, struct passwd **resptr); -#endif - -static void extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *fds_throttle); - -LocalManager *lmgmt = NULL; -FileManager *configFiles; - -StatProcessor *statProcessor; // Statistics Processors -AppVersionInfo appVersionInfo; // Build info for this application - -static inkcoreapi DiagsConfig *diagsConfig; -static char debug_tags[1024] = ; -static char action_tags[1024] = ; -static bool proxy_on = true; - -char mgmt_path[PATH_NAME_MAX + 1]; - -// By default, set the current directory as base -static const char *recs_conf = records.config; - -static int fds_limit; - -// TODO: Use positive instead negative selection -// Thsis should just be #if defined(solaris) -#if !defined(linux) !defined(freebsd) !defined(darwin) -static void SignalHandler(int sig, siginfo_t * t, void *f); -static void SignalAlrmHandler(int sig, siginfo_t * t, void *f); -#else -static void SignalHandler(int sig); -static void
[4/9] git commit: TS-2977: apply library naming conventions to librecords
TS-2977: apply library naming conventions to librecords Everywhere else foo_lm.a is the local manager variant, and foo_p.a is the process manager variant. Make librecords follow the same pattern. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/73865831 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/73865831 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/73865831 Branch: refs/heads/master Commit: 7386583197067f7a64de8f39bf0f10a59516c8fd Parents: 93f46af Author: James Peach jpe...@apache.org Authored: Thu Jul 31 10:52:32 2014 -0700 Committer: James Peach jpe...@apache.org Committed: Fri Aug 1 19:55:45 2014 -0700 -- cmd/traffic_cop/Makefile.am | 2 +- cmd/traffic_manager/Makefile.am | 4 +-- iocore/aio/Makefile.am | 2 +- iocore/eventsystem/Makefile.am | 2 +- lib/records/Makefile.am | 62 lib/records/RecProcess.cc | 2 +- lib/records/test_RecProcess.i | 2 +- proxy/Makefile.am | 10 +++--- 8 files changed, 33 insertions(+), 53 deletions(-) -- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/73865831/cmd/traffic_cop/Makefile.am -- diff --git a/cmd/traffic_cop/Makefile.am b/cmd/traffic_cop/Makefile.am index 653d4e7..cd7085b 100644 --- a/cmd/traffic_cop/Makefile.am +++ b/cmd/traffic_cop/Makefile.am @@ -36,5 +36,5 @@ traffic_cop_LDADD = \ $(top_builddir)/mgmt/api/libtsmgmtshare.la \ $(top_builddir)/mgmt/api/libtsmgmt.la \ $(top_builddir)/lib/ts/libtsutil.la \ - $(top_builddir)/lib/records/librec4cop.a \ + $(top_builddir)/lib/records/librecords_cop.a \ @LIBRESOLV@ @OPENSSL_LIBS@ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/73865831/cmd/traffic_manager/Makefile.am -- diff --git a/cmd/traffic_manager/Makefile.am b/cmd/traffic_manager/Makefile.am index 3b65181..1bb5614 100644 --- a/cmd/traffic_manager/Makefile.am +++ b/cmd/traffic_manager/Makefile.am @@ -32,7 +32,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/mgmt/web2 \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib -# + traffic_manager_SOURCES = \ AddConfigFilesHere.cc \ Main.cc \ @@ -48,7 +48,7 @@ traffic_manager_LDADD = \ $(top_builddir)/mgmt/api/libtsmgmtshare.la \ $(top_builddir)/mgmt/utils/libutils_lm.a \ $(top_builddir)/proxy/hdrs/libhdrs.a \ - $(top_builddir)/lib/records/libreclocal.a \ + $(top_builddir)/lib/records/librecords_lm.a \ $(top_builddir)/lib/ts/libtsutil.la \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ $(top_builddir)/proxy/shared/liberror.a \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/73865831/iocore/aio/Makefile.am -- diff --git a/iocore/aio/Makefile.am b/iocore/aio/Makefile.am index db25e37..51adaa2 100644 --- a/iocore/aio/Makefile.am +++ b/iocore/aio/Makefile.am @@ -50,7 +50,7 @@ test_AIO_CXXFLAGS = \ test_AIO_LDADD = \ libinkaio.a \ - $(top_builddir)/lib/records/librecprocess.a \ + $(top_builddir)/lib/records/librecords_p.a \ $(top_builddir)/mgmt/libmgmt_p.a \ $(top_builddir)/mgmt/utils/libutils_p.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/73865831/iocore/eventsystem/Makefile.am -- diff --git a/iocore/eventsystem/Makefile.am b/iocore/eventsystem/Makefile.am index cfa77e1..ce1a432 100644 --- a/iocore/eventsystem/Makefile.am +++ b/iocore/eventsystem/Makefile.am @@ -84,7 +84,7 @@ test_CXXFLAGS = \ test_LDADD = \ libinkevent.a \ - $(top_builddir)/lib/records/librecprocess.a \ + $(top_builddir)/lib/records/librecords_p.a \ $(top_builddir)/mgmt/libmgmt_p.a \ $(top_builddir)/mgmt/utils/libutils_p.a \ $(top_builddir)/iocore/eventsystem/libinkevent.a \ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/73865831/lib/records/Makefile.am -- diff --git a/lib/records/Makefile.am b/lib/records/Makefile.am index c291ac2..744194c 100644 --- a/lib/records/Makefile.am +++ b/lib/records/Makefile.am @@ -28,67 +28,47 @@ AM_CPPFLAGS = \ -I$(top_builddir)/lib \ -I$(top_srcdir)/lib/ts -noinst_LIBRARIES = libreclocal.a librecprocess.a librec4cop.a +noinst_LIBRARIES = librecords_lm.a librecords_p.a librecords_cop.a -libreclocal_a_SOURCES = \ +librecords_COMMON = \ I_RecAlarms.h \ I_RecCore.h \ I_RecDefs.h \ I_RecEvents.h \ - I_RecLocal.h \ + I_RecHttp.h \ I_RecMutex.h \ I_RecSignals.h \ - P_RecFile.h \ - P_RecCore.h \ P_RecCore.cc \ + P_RecCore.h \