Improve documentation, and simplify code

pull/13/head
Soner Tari 5 years ago
parent ad38b68ad7
commit 98c1186cb8

@ -275,7 +275,7 @@ pxy_thrmgr_timer_cb(UNUSED evutil_socket_t fd, UNUSED short what, UNUSED void *a
// @attention Print thread info only if stats logging is enabled, if disabled debug logs are not printed either
if (ctx->thrmgr->opts->statslog) {
ctx->timeout_count++;
if (ctx->timeout_count * ctx->thrmgr->opts->expired_conn_check_period >= ctx->thrmgr->opts->stats_period * ctx->thrmgr->opts->expired_conn_check_period) {
if (ctx->timeout_count >= ctx->thrmgr->opts->stats_period) {
ctx->timeout_count = 0;
pxy_thrmgr_print_thr_info(ctx);
}

@ -53,7 +53,12 @@ typedef struct pxy_thr_ctx {
struct event_base *evbase;
struct evdns_base *dnsbase;
int running;
unsigned int timeout_count;
// Per-thread locking is necessary during connection setup and termination
// to prevent multithreading issues between thrmgr thread and conn handling threads
pthread_mutex_t mutex;
// Statistics
evutil_socket_t max_fd;
size_t max_load;
size_t timedout_conns;
@ -64,10 +69,19 @@ typedef struct pxy_thr_ctx {
long long unsigned int intif_out_bytes;
long long unsigned int extif_in_bytes;
long long unsigned int extif_out_bytes;
// Each stats has an id, incremented on each stats print
unsigned short stats_id;
// Used to print statistics, compared against stats_period
unsigned int timeout_count;
// List of active connections on the thread
pxy_conn_ctx_t *conns;
// Per-thread sqlite stmt is necessary to prevent multithreading issues between threads
struct sqlite3_stmt *get_user;
pthread_mutex_t mutex;
// SSL conns wait for the first readcb to complete connection setup
// We keep track of conns at that stage using this list, to close them if they time out
pxy_conn_ctx_t *pending_ssl_conns;
long long unsigned int pending_ssl_conn_count;
} pxy_thr_ctx_t;
@ -76,6 +90,8 @@ struct pxy_thrmgr_ctx {
int num_thr;
opts_t *opts;
pxy_thr_ctx_t **thr;
// Provides unique conn id, always goes up, never down
// There is no risk of collision if/when it rolls back to 0
long long unsigned int conn_count;
};

Loading…
Cancel
Save