Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ case $host_os_def in
debug_opt="-g $common_opt"
release_opt="-g $common_opt $optimization_flags -axsse4.2 -fno-strict-aliasing"
cxx_opt="-Wno-invalid-offsetof"
TS_ADDTO([AM_LDFLAGS], [-Wl,-lstdc++])
])

AS_IF([test "x$ax_cv_c_compiler_vendor" = "xclang"], [
Expand Down
13 changes: 7 additions & 6 deletions include/tscore/ConsistentHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

#pragma once

#include "Hash.h"
#include "tscpp/util/Hash.h"
#include <cstdint>
#include <iostream>
#include <map>
#include <memory>

/*
Helper class to be extended to make ring nodes.
Expand All @@ -46,17 +47,17 @@ typedef std::map<uint64_t, ATSConsistentHashNode *>::iterator ATSConsistentHashI
*/

struct ATSConsistentHash {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you're in here, why is this a struct not a class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd have to ask @jrushford - I wanted to minimize the changes in this area, it's really outside the scope of the PR.

ATSConsistentHash(int r = 1024, ATSHash64 *h = nullptr);
void insert(ATSConsistentHashNode *node, float weight = 1.0, ATSHash64 *h = nullptr);
ATSConsistentHash(int r = 1024, ts::Hash64Functor *h = nullptr);
void insert(ATSConsistentHashNode *node, float weight = 1.0, ts::Hash64Functor *h = nullptr);
ATSConsistentHashNode *lookup(const char *url = nullptr, ATSConsistentHashIter *i = nullptr, bool *w = nullptr,
ATSHash64 *h = nullptr);
ts::Hash64Functor *h = nullptr);
ATSConsistentHashNode *lookup_available(const char *url = nullptr, ATSConsistentHashIter *i = nullptr, bool *w = nullptr,
ATSHash64 *h = nullptr);
ts::Hash64Functor *h = nullptr);
ATSConsistentHashNode *lookup_by_hashval(uint64_t hashval, ATSConsistentHashIter *i = nullptr, bool *w = nullptr);
~ATSConsistentHash();

private:
int replicas;
ATSHash64 *hash;
std::unique_ptr<ts::Hash64Functor> hash;
std::map<uint64_t, ATSConsistentHashNode *> NodeMap;
};
6 changes: 2 additions & 4 deletions include/tscore/EnumDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
#include <string_view>
#include <unordered_map>

#include "tscore/HashFNV.h"
#include "tscpp/util/HashFNV.h"

/// Hash functor for @c string_view
inline size_t
TsLuaConfigSVHash(std::string_view const &sv)
{
ATSHash64FNV1a h;
h.update(sv.data(), sv.size());
return h.get();
return ts::Hash64FNV1a().hash_immediate(sv);
}

class TsEnumDescriptor
Expand Down
65 changes: 0 additions & 65 deletions include/tscore/Hash.h

This file was deleted.

93 changes: 0 additions & 93 deletions include/tscore/HashFNV.h

This file was deleted.

34 changes: 22 additions & 12 deletions include/tscore/HashMD5.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,31 @@

#pragma once

#include "tscore/Hash.h"
#include "tscpp/util/Hash.h"
#include <openssl/evp.h>

struct ATSHashMD5 : ATSHash {
ATSHashMD5(void);
void update(const void *data, size_t len) override;
void final(void) override;
const void *get(void) const override;
size_t size(void) const override;
void clear(void) override;
~ATSHashMD5() override;
namespace ts
{
struct HashMD5 : HashFunctor {
HashMD5();

HashMD5 &update(std::string_view const &data) override;

HashMD5 & final() override;

bool get(MemSpan dst) const override;

size_t size() const override;

HashMD5 &clear() override;

~HashMD5() override;

private:
EVP_MD_CTX *ctx;
EVP_MD_CTX *ctx{nullptr};
unsigned char md_value[EVP_MAX_MD_SIZE];
unsigned int md_len;
bool finalized;
unsigned int md_len{0};
bool finalized{false};
};

} // namespace ts
Loading