ssl stream增加统计

This commit is contained in:
zhengchao
2018-08-31 19:59:22 +08:00
parent fd216a51de
commit baa409ecc8
5 changed files with 137 additions and 23 deletions

View File

@@ -2,6 +2,7 @@
#include <ssl_sess_cache.h>
#include <ssl_utils.h>
#include <tfe_utils.h>
#include <MESA/MESA_htable.h>
#include <MESA/field_stat2.h>
@@ -189,9 +190,7 @@ void up_session_set(struct sess_cache * cache, struct sockaddr * addr, socklen_t
struct asn1_sess * asn1 = NULL;
asn1 = ssl_sess_serialize(sess);
struct sess_set_args set_args;
set_args.hash = cache->hash;
set_args.new_sess = asn1;
struct sess_set_args set_args{.hash = cache->hash, .new_sess = asn1};
no_use = MESA_htable_search_cb(cache->hash, key, key_size, sess_cache_set_cb, &set_args, &cb_ret);
if (cb_ret == SESS_CACHE_UPDATE_OLD)
{
@@ -217,12 +216,12 @@ SSL_SESSION * up_session_get(struct sess_cache * cache, struct sockaddr * addr,
key = NULL;
if (cb_ret == 1)
{
cache->hit_cnt++;
ATOMIC_INC(&(cache->hit_cnt));
return sess;
}
else
{
cache->miss_cnt++;
ATOMIC_INC(&(cache->miss_cnt));
return NULL;
}
}
@@ -263,12 +262,12 @@ SSL_SESSION * down_session_get(struct sess_cache * cache, const unsigned char *
no_use = MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_get_cb, &sess, &cb_ret);
if (cb_ret == 1)
{
cache->hit_cnt++;
ATOMIC_INC(&(cache->hit_cnt));
return sess;
}
else
{
cache->miss_cnt++;
ATOMIC_INC(&(cache->miss_cnt));
return NULL;
}
}
@@ -281,7 +280,7 @@ void down_session_del(struct sess_cache * cache, const SSL_SESSION * sess)
int ret = MESA_htable_del(cache->hash, id, len, NULL);
if (ret != MESA_HTABLE_RET_OK)
{
cache->del_err++;
ATOMIC_INC(&(cache->del_err));
}
return;
}