fieldstat增加sigpipe计数。

This commit is contained in:
zhengchao
2018-10-05 14:34:51 +08:00
parent 7fd3f5d1fb
commit 9ec072343b
7 changed files with 47 additions and 47 deletions

View File

@@ -32,6 +32,7 @@
#include <kni_acceptor.h>
#include <tcp_stream.h>
#include <MESA/MESA_prof_load.h>
#include <MESA/field_stat2.h>
#include <tfe_plugin.h>
static int signals[] = {SIGTERM, SIGQUIT, SIGHUP, SIGPIPE, SIGUSR1};
@@ -127,6 +128,7 @@ static void __signal_handler_cb(evutil_socket_t fd, short what, void * arg)
case SIGUSR1:
break;
case SIGPIPE:
ATOMIC_INC(&(ctx->stat_val[STAT_SIGPIPE]));
TFE_LOG_ERROR(ctx->logger, "Warning: Received SIGPIPE; ignoring.\n");
break;
default:
@@ -138,6 +140,12 @@ static void __signal_handler_cb(evutil_socket_t fd, short what, void * arg)
static void __gc_handler_cb(evutil_socket_t fd, short what, void * arg)
{
tfe_proxy * ctx = (tfe_proxy *) arg;
int i=0;
for(i=0;i<TFE_STAT_MAX;i++)
{
FS_operate(ctx->fs_handle, ctx->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(ctx->stat_val[i])));
}
FS_passive_output(ctx->fs_handle);
return;
}
@@ -205,6 +213,31 @@ int tfe_proxy_config(struct tfe_proxy * proxy, const char * profile)
return 0;
}
int tfe_stat_init(struct tfe_proxy * proxy, const char * profile)
{
const char* fieldstat_output="./tfe.fieldstat";
const char* app_name="tfe3a";
int value=0, i=0;
screen_stat_handle_t fs_handle=NULL;
fs_handle=FS_create_handle();
FS_set_para(fs_handle, OUTPUT_DEVICE, fieldstat_output, strlen(fieldstat_output)+1);
value=1;
FS_set_para(fs_handle, PRINT_MODE, &value, sizeof(value));
value=0;
FS_set_para(fs_handle, CREATE_THREAD, &value, sizeof(value));
FS_set_para(fs_handle, APP_NAME, app_name, strlen(app_name)+1);
const char* spec[TFE_STAT_MAX];
spec[STAT_SIGPIPE]="sigpipe";
for(i=0;i<TFE_STAT_MAX; i++)
{
proxy->fs_id[i]=FS_register(fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT,spec[i]);
}
FS_start(fs_handle);
proxy->fs_handle=fs_handle;
return 0;
}
#define CHECK_OR_EXIT(condition, fmt, ...) \
@@ -213,7 +246,6 @@ do { if(!(condition)) { TFE_LOG_ERROR(g_default_logger, fmt, ##__VA_ARGS__); exi
int main(int argc, char *argv[])
{
const char* main_profile="./conf/tfe.conf";
const char* fieldstat_output="./tfe.fieldstat";
g_default_logger = MESA_create_runtime_log_handle("log/tfe.log", RLOG_LV_DEBUG);
if (unlikely(g_default_logger == NULL))
@@ -234,15 +266,8 @@ int main(int argc, char *argv[])
CHECK_OR_EXIT(ret == 0, "Failed at loading profile %s, Exit.", main_profile);
/* PERFOMANCE MONITOR */
g_default_proxy->fs_handle=FS_create_handle();
FS_set_para(g_default_proxy->fs_handle, OUTPUT_DEVICE, fieldstat_output, strlen(fieldstat_output)+1);
int value=1;
FS_set_para(g_default_proxy->fs_handle, PRINT_MODE, &value, sizeof(value));
value=0;
FS_set_para(g_default_proxy->fs_handle, CREATE_THREAD, &value, sizeof(value));
FS_set_para(g_default_proxy->fs_handle, APP_NAME, g_default_proxy->name, strlen(g_default_proxy->name)+1);
FS_start(g_default_proxy->fs_handle);
tfe_stat_init(g_default_proxy, main_profile);
/* LOGGER */
g_default_proxy->logger = g_default_logger;