消除tfe_utils.之外的编译警告
This commit is contained in:
@@ -4,6 +4,7 @@ project(tfe)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -Wall)
|
||||
|
||||
add_subdirectory(vendor)
|
||||
add_subdirectory(common)
|
||||
|
||||
@@ -136,10 +136,9 @@ struct future * future_create(const char* symbol, future_success_cb * cb_success
|
||||
strncpy(p->f.symbol,symbol,sizeof(p->f.symbol));
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC,&p->debug.create_time);
|
||||
void * no_use = NULL;
|
||||
long cb_ret=0;
|
||||
struct field_get_set_args args={.htable = g_FP_instance.name_table, .fs_handle = g_FP_instance.fs_handle};
|
||||
no_use=MESA_htable_search_cb(g_FP_instance.name_table, (const unsigned char*)symbol, strlen(symbol), field_get_set_cb, &args, &cb_ret);
|
||||
MESA_htable_search_cb(g_FP_instance.name_table, (const unsigned char*)symbol, strlen(symbol), field_get_set_cb, &args, &cb_ret);
|
||||
p->debug.fsid_latency=args.fsid_latency;
|
||||
p->debug.fsid_failed=args.fsid_failed;
|
||||
FS_operate(g_FP_instance.fs_handle,g_FP_instance.fsid_f_num, 0, FS_OP_ADD, 1);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
#include <string.h>
|
||||
void* tfe_stat_init(void* fs_handle)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void tfe_stat_flush(void* handle)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,20 +231,19 @@ static X509* get_cert_from_response(const char* data, int len, void* logger)
|
||||
|
||||
static EVP_PKEY* get_key_from_response(const char* data, int len, void* logger)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static STACK_OF(X509)* get_chain_from_response(const char* data, int len, void* logger)
|
||||
{
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void certstore_rpc_on_succ(void* result, void* user)
|
||||
{
|
||||
struct promise * p = (struct promise *) user;
|
||||
struct key_keeper_promise_ctx* ctx = (struct key_keeper_promise_ctx*)promise_get_ctx(p);
|
||||
void* logger = ctx->logger;
|
||||
MESA_htable_handle htable= ctx->htable;
|
||||
const uchar* key = ctx->key;
|
||||
unsigned int key_len = ctx->key_len;
|
||||
@@ -265,7 +264,6 @@ static void certstore_rpc_on_succ(void* result, void* user)
|
||||
keyring_set_chain(ring, chain);
|
||||
promise_success(p, (void*)ring);
|
||||
|
||||
keyring_ref_inc(ring);
|
||||
int ret = MESA_htable_add(htable, key, key_len, (void*)ring);
|
||||
if(ret<0)
|
||||
{
|
||||
@@ -289,20 +287,7 @@ static STACK_OF(X509)* get_chain_from_response(const char* data, int len, void*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
static void key_keeper_free_serialized()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void key_keeper_verify_cb()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
struct key_keeper *
|
||||
key_keeper_init(const char * profile, const char* section, void* logger)
|
||||
struct key_keeper* key_keeper_init(const char * profile, const char* section, void* logger)
|
||||
{
|
||||
//load conf
|
||||
//TODO free
|
||||
@@ -330,10 +315,6 @@ struct keyring* key_keeper_release_keyring(future_result_t* result)
|
||||
return &(kyr->head);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void ctx_destory_cb(struct promise* p)
|
||||
{
|
||||
|
||||
@@ -347,6 +328,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
//current promise, belong to key_keeper
|
||||
struct promise* p = future_to_promise(f);
|
||||
struct key_keeper_promise_ctx* ctx = ALLOC(struct key_keeper_promise_ctx, 1);
|
||||
//TODO free ctx!!
|
||||
unsigned int len = 0;
|
||||
const uchar* key = get_key_by_cert(origin_cert, keyring_id, &len);
|
||||
ctx->logger = keeper->logger;
|
||||
@@ -382,7 +364,7 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
struct keyring_private* ring = generate_x509_keyring(origin_cert, keyring_id, filename);
|
||||
if(ring)
|
||||
{
|
||||
keyring_ref_inc(ring);
|
||||
promise_success(p, (void*)ring);
|
||||
int ret = MESA_htable_add(ctx->htable, ctx->key, ctx->key_len, (void*)ring);
|
||||
if(ret<0)
|
||||
{
|
||||
@@ -392,8 +374,6 @@ void key_keeper_async_ask(struct future * f, struct key_keeper * keeper, const c
|
||||
{
|
||||
printf("key %s is added to hash table\n", ctx->key);
|
||||
}
|
||||
promise_success(p, (void*)ring);
|
||||
key_keeper_free_keyring((struct keyring*)ring);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -180,10 +180,8 @@ void up_session_set(struct sess_cache * cache, struct sockaddr * addr, socklen_t
|
||||
SSL_SESSION * sess)
|
||||
{
|
||||
unsigned char * key = NULL;
|
||||
int ret = 0;
|
||||
size_t key_size = 0;
|
||||
long cb_ret = 0;
|
||||
void * no_use = NULL;
|
||||
assert(cache->served_for == CONN_DIR_UPSTREAM);
|
||||
key_size = upsess_mk_key(addr, addr_len, sni, &key);
|
||||
|
||||
@@ -191,7 +189,7 @@ void up_session_set(struct sess_cache * cache, struct sockaddr * addr, socklen_t
|
||||
asn1 = ssl_sess_serialize(sess);
|
||||
|
||||
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);
|
||||
MESA_htable_search_cb(cache->hash, key, key_size, sess_cache_set_cb, &set_args, &cb_ret);
|
||||
if (cb_ret == SESS_CACHE_UPDATE_OLD)
|
||||
{
|
||||
ssl_sess_free_serialized(asn1);
|
||||
@@ -203,7 +201,6 @@ void up_session_set(struct sess_cache * cache, struct sockaddr * addr, socklen_t
|
||||
SSL_SESSION * up_session_get(struct sess_cache * cache, struct sockaddr * addr, socklen_t addr_len, const char * sni)
|
||||
{
|
||||
SSL_SESSION * sess = NULL;
|
||||
void * no_use = NULL;
|
||||
long cb_ret = 0;
|
||||
|
||||
size_t key_size = 0;
|
||||
@@ -211,7 +208,7 @@ SSL_SESSION * up_session_get(struct sess_cache * cache, struct sockaddr * addr,
|
||||
|
||||
unsigned char * key = NULL;
|
||||
key_size = upsess_mk_key(addr, addr_len, sni, &key);
|
||||
no_use = MESA_htable_search_cb(cache->hash, key, key_size, sess_cache_get_cb, &sess, &cb_ret);
|
||||
MESA_htable_search_cb(cache->hash, key, key_size, sess_cache_get_cb, &sess, &cb_ret);
|
||||
free(key);
|
||||
key = NULL;
|
||||
if (cb_ret == 1)
|
||||
@@ -231,8 +228,6 @@ void down_session_set(struct sess_cache * cache, const SSL_SESSION * sess)
|
||||
unsigned int idlen = 0;
|
||||
struct asn1_sess * asn1 = NULL;
|
||||
long cb_ret = 0;
|
||||
void * no_use = NULL;
|
||||
int ret = 0;
|
||||
assert(cache->served_for == CONN_DIR_DOWNSTREAM);
|
||||
asn1 = ssl_sess_serialize((SSL_SESSION *) sess);
|
||||
|
||||
@@ -245,7 +240,7 @@ void down_session_set(struct sess_cache * cache, const SSL_SESSION * sess)
|
||||
const unsigned char * id = SSL_SESSION_get_id(sess, &idlen);
|
||||
struct sess_set_args set_args{.hash = cache->hash, .new_sess = asn1};
|
||||
|
||||
no_use = MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_set_cb, &set_args, &cb_ret);
|
||||
MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_set_cb, &set_args, &cb_ret);
|
||||
if (cb_ret == SESS_CACHE_UPDATE_OLD)
|
||||
{
|
||||
ssl_sess_free_serialized(asn1);
|
||||
@@ -256,10 +251,9 @@ void down_session_set(struct sess_cache * cache, const SSL_SESSION * sess)
|
||||
SSL_SESSION * down_session_get(struct sess_cache * cache, const unsigned char * id, int idlen)
|
||||
{
|
||||
SSL_SESSION * sess = NULL;
|
||||
void * no_use = NULL;
|
||||
long cb_ret = 0;
|
||||
assert(cache->served_for == CONN_DIR_DOWNSTREAM);
|
||||
no_use = MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_get_cb, &sess, &cb_ret);
|
||||
MESA_htable_search_cb(cache->hash, id, (unsigned int) idlen, sess_cache_get_cb, &sess, &cb_ret);
|
||||
if (cb_ret == 1)
|
||||
{
|
||||
ATOMIC_INC(&(cache->hit_cnt));
|
||||
|
||||
@@ -365,7 +365,7 @@ struct ssl_mgr * ssl_manager_init(const char * ini_profile, const char * section
|
||||
{
|
||||
struct timeval gc_delay = {0, 500*1000}; //Microseconds, we set 500 miliseconds here.
|
||||
struct ssl_mgr * mgr = ALLOC(struct ssl_mgr, 1);
|
||||
int ret = 0, value = 0;
|
||||
int ret = 0;
|
||||
char version_str[TFE_SYMBOL_MAX];
|
||||
mgr->logger = logger;
|
||||
mgr->ev_base_gc=ev_base_gc;
|
||||
@@ -498,10 +498,7 @@ static void peek_client_hello_cb(evutil_socket_t fd, short what, void * arg)
|
||||
struct promise * promise = (struct promise *) arg;
|
||||
//use promise_get_ctx instead of promise_dettach_ctx for try more times.
|
||||
struct peek_client_hello_ctx * ctx = (struct peek_client_hello_ctx *) promise_get_ctx(promise);
|
||||
const char * reason_too_many_retries = "too many tries";
|
||||
const char * reason_see_no_client_hello = "see no client hello";
|
||||
const char * reason = NULL;
|
||||
char * sni = NULL;
|
||||
unsigned char buf[1024];
|
||||
ssize_t n = 0;
|
||||
const unsigned char * chello = NULL;
|
||||
@@ -1097,7 +1094,7 @@ void query_cert_ctx_free(struct ask_keyring_ctx * ctx)
|
||||
future_destroy(ctx->f_query_cert);
|
||||
ctx->f_query_cert = NULL;
|
||||
}
|
||||
|
||||
//on success, bev_down and downstream has been transfered to caller by release**
|
||||
if (ctx->bev_down != NULL)
|
||||
{
|
||||
bufferevent_free(ctx->bev_down);
|
||||
@@ -1137,15 +1134,15 @@ void ask_keyring_on_succ(void * result, void * user)
|
||||
struct promise * p = (struct promise *) user;
|
||||
struct ask_keyring_ctx * ctx = (struct ask_keyring_ctx *) promise_dettach_ctx(p);
|
||||
|
||||
struct ssl_stream * downstream = NULL;
|
||||
struct keyring * kyr = NULL;
|
||||
|
||||
struct ssl_mgr * mgr = ctx->ssl_mgr;
|
||||
|
||||
|
||||
|
||||
kyr = key_keeper_release_keyring(result); //kyr will be freed at ssl downstream closing.
|
||||
future_destroy(ctx->f_query_cert);
|
||||
ctx->f_query_cert = NULL;
|
||||
|
||||
kyr = key_keeper_release_keyring(result); //kyr will be freed at ssl downstream closing.
|
||||
ctx->downstream = ssl_stream_new(mgr, ctx->fd_downstream, CONN_DIR_DOWNSTREAM, NULL, kyr);
|
||||
ctx->bev_down = bufferevent_openssl_socket_new(ctx->evbase, ctx->fd_downstream, ctx->downstream->ssl,
|
||||
BUFFEREVENT_SSL_CONNECTING, BEV_OPT_DEFER_CALLBACKS);
|
||||
@@ -1292,14 +1289,15 @@ retry:
|
||||
if (ctx->ev)
|
||||
{
|
||||
event_add(ctx->ev, &retry_delay);
|
||||
return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
TFE_LOG_ERROR(logger, "Failed to shutdown SSL connection cleanly: "
|
||||
"Cannot create event. Closing fd.\n");
|
||||
|
||||
}
|
||||
return;
|
||||
complete:
|
||||
if(ctx->s_stream->dir=CONN_DIR_DOWNSTREAM)
|
||||
if(ctx->s_stream->dir==CONN_DIR_DOWNSTREAM)
|
||||
{
|
||||
ATOMIC_INC(&(ctx->s_stream->mgr->stat_val[SSL_DOWN_CLOSED]));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ int tfe_stream_write(const struct tfe_stream * stream, enum tfe_conn_dir dir, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
static tfe_conn_private * __conn_private_create(struct tfe_stream_private * stream, struct bufferevent * bev)
|
||||
static tfe_conn_private * __conn_private_create_by_bev(struct tfe_stream_private * stream, struct bufferevent * bev)
|
||||
{
|
||||
struct tfe_conn_private * __conn_private = ALLOC(struct tfe_conn_private, 1);
|
||||
__conn_private->bev = bev;
|
||||
@@ -160,7 +160,6 @@ static void __conn_private_destory(struct tfe_conn_private * conn)
|
||||
static void __stream_bev_passthrough_readcb(struct bufferevent * bev, void * arg)
|
||||
{
|
||||
struct tfe_stream_private * _stream = (struct tfe_stream_private *) arg;
|
||||
struct tfe_conn_private * this_conn = __THIS_CONN(_stream, __BEV_DIR(_stream, bev));
|
||||
struct tfe_conn_private * peer_conn = __PEER_CONN(_stream, __BEV_DIR(_stream, bev));
|
||||
|
||||
struct evbuffer * __input_buffer = bufferevent_get_input(bev);
|
||||
@@ -275,10 +274,9 @@ static void __stream_bev_readcb(struct bufferevent * bev, void * arg)
|
||||
{
|
||||
struct tfe_stream_private * _stream = (struct tfe_stream_private *) arg;
|
||||
enum tfe_conn_dir dir = __BEV_DIR(_stream, bev);
|
||||
struct tfe_conn_private * this_conn = __THIS_CONN(_stream, dir);
|
||||
struct tfe_conn_private * peer_conn = __PEER_CONN(_stream, dir);
|
||||
|
||||
int i = 0, ret = 0;
|
||||
int i = 0;
|
||||
enum tfe_stream_action action_tmp = ACTION_FORWARD_DATA, action_final = ACTION_FORWARD_DATA;
|
||||
|
||||
const struct tfe_plugin * plugins = _stream->thread_ref->modules;
|
||||
@@ -373,10 +371,9 @@ static void __stream_bev_writecb(struct bufferevent * bev, void * arg)
|
||||
{
|
||||
struct tfe_stream_private * _stream = (struct tfe_stream_private *) arg;
|
||||
enum tfe_conn_dir dir = __BEV_DIR(_stream, bev);
|
||||
struct tfe_conn_private * this_conn = __THIS_CONN(_stream, dir);
|
||||
struct tfe_conn_private * peer_conn = __PEER_CONN(_stream, dir);
|
||||
|
||||
struct evbuffer * outbuf = bufferevent_get_output(bev);
|
||||
// struct evbuffer * outbuf = bufferevent_get_output(bev);
|
||||
|
||||
if (peer_conn->bev && !(bufferevent_get_enabled(peer_conn->bev) & EV_READ))
|
||||
{
|
||||
@@ -436,7 +433,7 @@ call_plugin_close:
|
||||
return;
|
||||
}
|
||||
|
||||
static tfe_conn_private * __conn_private_create(struct tfe_stream_private * stream, evutil_socket_t fd)
|
||||
static tfe_conn_private * __conn_private_create_by_fd(struct tfe_stream_private * stream, evutil_socket_t fd)
|
||||
{
|
||||
struct tfe_conn_private * __conn_private = ALLOC(struct tfe_conn_private, 1);
|
||||
struct event_base * __ev_base = stream->thread_ref->evbase;
|
||||
@@ -481,7 +478,7 @@ void ssl_downstream_create_on_success(future_result_t * result, void * user)
|
||||
struct ssl_stream * downstream = ssl_downstream_create_result_release_stream(result);
|
||||
struct bufferevent * bev = ssl_downstream_create_result_release_bev(result);
|
||||
|
||||
_stream->conn_downstream = __conn_private_create(_stream, bev);
|
||||
_stream->conn_downstream = __conn_private_create_by_bev(_stream, bev);
|
||||
_stream->ssl_downstream = downstream;
|
||||
|
||||
future_destroy(_stream->future_downstream_create);
|
||||
@@ -510,7 +507,7 @@ void ssl_upstream_create_on_success(future_result_t * result, void * user)
|
||||
assert(upstream != NULL && bev != NULL);
|
||||
|
||||
/* Create connection ctx by bev */
|
||||
_stream->conn_upstream = __conn_private_create(_stream, bev);
|
||||
_stream->conn_upstream = __conn_private_create_by_bev(_stream, bev);
|
||||
_stream->ssl_upstream = upstream;
|
||||
|
||||
future_destroy(_stream->future_upstream_create);
|
||||
@@ -541,7 +538,6 @@ struct tfe_stream * tfe_stream_create(struct tfe_proxy * pxy, struct tfe_thread_
|
||||
void tfe_stream_destory(struct tfe_stream_private * stream)
|
||||
{
|
||||
struct tfe_thread_ctx * thread = stream->thread_ref;
|
||||
struct tfe_proxy * proxy = stream->proxy_ref;
|
||||
struct event_base * ev_base = thread->evbase;
|
||||
|
||||
if (__IS_SSL(stream) && stream->ssl_upstream)
|
||||
@@ -585,7 +581,7 @@ void tfe_stream_destory(struct tfe_stream_private * stream)
|
||||
{
|
||||
future_destroy(stream->future_upstream_create);
|
||||
}
|
||||
|
||||
stream->proxy_ref=NULL;
|
||||
free(stream);
|
||||
thread->load--;
|
||||
}
|
||||
@@ -603,8 +599,8 @@ void tfe_stream_init_by_fds(struct tfe_stream * stream, evutil_socket_t fd_downs
|
||||
|
||||
if (_stream->session_type == STREAM_PROTO_PLAIN)
|
||||
{
|
||||
_stream->conn_downstream = __conn_private_create(_stream, fd_downstream);
|
||||
_stream->conn_upstream = __conn_private_create(_stream, fd_upstream);
|
||||
_stream->conn_downstream = __conn_private_create_by_fd(_stream, fd_downstream);
|
||||
_stream->conn_upstream = __conn_private_create_by_fd(_stream, fd_upstream);
|
||||
|
||||
assert(_stream->conn_downstream != NULL);
|
||||
assert(_stream->conn_upstream != NULL);
|
||||
|
||||
@@ -211,10 +211,10 @@ tfe_rpc_async_ask(struct future* f, struct tfe_rpc* rpc, const char* url, int me
|
||||
evhttp_add_header(evhttp_request_get_output_headers(request), "Host", host);
|
||||
switch(method)
|
||||
{
|
||||
GET:
|
||||
case GET:
|
||||
evhttp_make_request(connection, request, EVHTTP_REQ_GET, request_url);
|
||||
break;
|
||||
POST:
|
||||
case POST:
|
||||
evbuffer_add(request->output_buffer, data, data_len);
|
||||
evhttp_make_request(connection, request, EVHTTP_REQ_POST, request_url);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user