Suppress 'TraceEventFieldNotFound' event. Don't suppress simultaneous FDBLibTLSVerifyFailure events (this requires including flow.h and removing the copied version of Reference/ReferenceCounted in FDBLibTLS).
This commit is contained in:
parent
b2a5d056d0
commit
d3c1f9afbd
|
@ -6,8 +6,7 @@ set(SRCS
|
|||
FDBLibTLSSession.cpp
|
||||
FDBLibTLSSession.h
|
||||
FDBLibTLSVerify.cpp
|
||||
FDBLibTLSVerify.h
|
||||
ReferenceCounted.h)
|
||||
FDBLibTLSVerify.h)
|
||||
|
||||
add_library(FDBLibTLS ${SRCS})
|
||||
target_link_libraries(FDBLibTLS PUBLIC LibreSSL boost_target)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fdbrpc/ITLSPlugin.h"
|
||||
#include "ReferenceCounted.h"
|
||||
#include "flow/FastRef.h"
|
||||
|
||||
#include <tls.h>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fdbrpc/ITLSPlugin.h"
|
||||
#include "ReferenceCounted.h"
|
||||
#include "flow/FastRef.h"
|
||||
|
||||
#include "FDBLibTLS/FDBLibTLSPlugin.h"
|
||||
#include "FDBLibTLS/FDBLibTLSVerify.h"
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
*/
|
||||
|
||||
#include "FDBLibTLS/FDBLibTLSSession.h"
|
||||
|
||||
#include "flow/flow.h"
|
||||
#include "flow/Trace.h"
|
||||
|
||||
#include <openssl/bio.h>
|
||||
|
@ -60,7 +62,7 @@ static ssize_t tls_write_func(struct tls *ctx, const void *buf, size_t buflen, v
|
|||
|
||||
FDBLibTLSSession::FDBLibTLSSession(Reference<FDBLibTLSPolicy> policy, bool is_client, const char* servername, TLSSendCallbackFunc send_func, void* send_ctx, TLSRecvCallbackFunc recv_func, void* recv_ctx, void* uidptr) :
|
||||
tls_ctx(NULL), tls_sctx(NULL), is_client(is_client), policy(policy), send_func(send_func), send_ctx(send_ctx),
|
||||
recv_func(recv_func), recv_ctx(recv_ctx), handshake_completed(false) {
|
||||
recv_func(recv_func), recv_ctx(recv_ctx), handshake_completed(false), lastVerifyFailureLogged(0.0) {
|
||||
if (uidptr)
|
||||
uid = * (UID*) uidptr;
|
||||
|
||||
|
@ -344,8 +346,11 @@ bool FDBLibTLSSession::verify_peer() {
|
|||
|
||||
if (!rc) {
|
||||
// log the various failure reasons
|
||||
for (std::string reason : verify_failure_reasons) {
|
||||
TraceEvent("FDBLibTLSVerifyFailure", uid).suppressFor(1.0).detail("Reason", reason);
|
||||
if(now() - lastVerifyFailureLogged > 1.0) {
|
||||
for (std::string reason : verify_failure_reasons) {
|
||||
lastVerifyFailureLogged = now();
|
||||
TraceEvent("FDBLibTLSVerifyFailure", uid).detail("Reason", reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "fdbrpc/ITLSPlugin.h"
|
||||
#include "ReferenceCounted.h"
|
||||
#include "flow/FastRef.h"
|
||||
|
||||
#include "FDBLibTLS/FDBLibTLSPolicy.h"
|
||||
#include "FDBLibTLS/FDBLibTLSVerify.h"
|
||||
|
@ -61,6 +61,7 @@ struct FDBLibTLSSession : ITLSSession, ReferenceCounted<FDBLibTLSSession> {
|
|||
bool handshake_completed;
|
||||
|
||||
UID uid;
|
||||
double lastVerifyFailureLogged;
|
||||
};
|
||||
|
||||
#endif /* FDB_LIBTLS_SESSION_H */
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ReferenceCounted.h"
|
||||
#include "flow/FastRef.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* ReferenceCounted.h
|
||||
*
|
||||
* This source file is part of the FoundationDB open source project
|
||||
*
|
||||
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#ifndef FDB_REFERENCE_COUNTED_H
|
||||
#define FDB_REFERENCE_COUNTED_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
template <class T>
|
||||
struct ReferenceCounted {
|
||||
void addref() { ++referenceCount; }
|
||||
void delref() { if (--referenceCount == 0) { delete (T*)this; } }
|
||||
|
||||
ReferenceCounted() : referenceCount(1) {}
|
||||
|
||||
private:
|
||||
ReferenceCounted(const ReferenceCounted&) = delete;
|
||||
void operator=(const ReferenceCounted&) = delete;
|
||||
int32_t referenceCount;
|
||||
};
|
||||
|
||||
template <class P>
|
||||
void addref(P* ptr) { ptr->addref(); }
|
||||
template <class P>
|
||||
void delref(P* ptr) { ptr->delref(); }
|
||||
|
||||
template <class P>
|
||||
struct Reference {
|
||||
Reference() : ptr(NULL) {}
|
||||
explicit Reference( P* ptr ) : ptr(ptr) {}
|
||||
static Reference<P> addRef( P* ptr ) { ptr->addref(); return Reference(ptr); }
|
||||
|
||||
Reference(const Reference& r) : ptr(r.getPtr()) { if (ptr) addref(ptr); }
|
||||
Reference(Reference && r) : ptr(r.getPtr()) { r.ptr = NULL; }
|
||||
|
||||
template <class Q>
|
||||
Reference(const Reference<Q>& r) : ptr(r.getPtr()) { if (ptr) addref(ptr); }
|
||||
template <class Q>
|
||||
Reference(Reference<Q> && r) : ptr(r.getPtr()) { r.setPtrUnsafe(NULL); }
|
||||
|
||||
~Reference() { if (ptr) delref(ptr); }
|
||||
Reference& operator=(const Reference& r) {
|
||||
P* oldPtr = ptr;
|
||||
P* newPtr = r.ptr;
|
||||
if (oldPtr != newPtr) {
|
||||
if (newPtr) addref(newPtr);
|
||||
ptr = newPtr;
|
||||
if (oldPtr) delref(oldPtr);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
Reference& operator=(Reference&& r) {
|
||||
P* oldPtr = ptr;
|
||||
P* newPtr = r.ptr;
|
||||
if (oldPtr != newPtr) {
|
||||
r.ptr = NULL;
|
||||
ptr = newPtr;
|
||||
if (oldPtr) delref(oldPtr);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
P* oldPtr = ptr;
|
||||
if (oldPtr) {
|
||||
ptr = NULL;
|
||||
delref(oldPtr);
|
||||
}
|
||||
}
|
||||
|
||||
P* operator->() const { return ptr; }
|
||||
P& operator*() const { return *ptr; }
|
||||
P* getPtr() const { return ptr; }
|
||||
|
||||
void setPtrUnsafe( P* p ) { ptr = p; }
|
||||
|
||||
P* extractPtr() { auto *p = ptr; ptr = NULL; return p; }
|
||||
|
||||
bool boolean_test() const { return ptr != 0; }
|
||||
private:
|
||||
P *ptr;
|
||||
};
|
||||
|
||||
template <class P>
|
||||
bool operator==( const Reference<P>& lhs, const Reference<P>& rhs ) {
|
||||
return lhs.getPtr() == rhs.getPtr();
|
||||
}
|
||||
|
||||
#endif /* FDB_REFERENCE_COUNTED_H */
|
|
@ -31,7 +31,6 @@
|
|||
#include <boost/circular_buffer.hpp>
|
||||
|
||||
#include "fdbrpc/ITLSPlugin.h"
|
||||
#include "ReferenceCounted.h"
|
||||
|
||||
#include "FDBLibTLS/FDBLibTLSPlugin.h"
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <openssl/objects.h>
|
||||
|
||||
#include "fdbrpc/ITLSPlugin.h"
|
||||
#include "ReferenceCounted.h"
|
||||
|
||||
#include "FDBLibTLS/FDBLibTLSPlugin.h"
|
||||
#include "FDBLibTLS/FDBLibTLSPolicy.h"
|
||||
|
|
|
@ -1135,6 +1135,7 @@ std::string TraceEventFields::getValue(std::string key) const {
|
|||
}
|
||||
else {
|
||||
TraceEvent ev(SevWarn, "TraceEventFieldNotFound");
|
||||
ev.suppressFor(1.0);
|
||||
if(tryGetValue("Type", value)) {
|
||||
ev.detail("Event", value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue