From 72167f99bb90e3ac85ce067c442d80be1d225b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=83=E4=B9=99?= Date: Wed, 13 Dec 2017 13:48:21 +0800 Subject: [PATCH] [modify] refine ststoken switch --- src/log_producer_config.c | 3 ++- src/log_producer_config.h | 2 +- src/log_producer_sender.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/log_producer_config.c b/src/log_producer_config.c index 4c791cc..330de68 100644 --- a/src/log_producer_config.c +++ b/src/log_producer_config.c @@ -407,7 +407,8 @@ void log_producer_config_set_sts_token(log_producer_config * config, const char char * tmpBuf = (char *)malloc(tokenLen + 1); strncpy(tmpBuf, token, tokenLen); tmpBuf[tokenLen] = '\0'; - char * oldToken = (char *)apr_atomic_xchgptr((volatile void **)&config->stsToken, tmpBuf); + void * stsTokenPtr = (void *)&config->stsToken; + char * oldToken = (char *)apr_atomic_xchgptr(stsTokenPtr, tmpBuf); if (oldToken != NULL) { free(oldToken); diff --git a/src/log_producer_config.h b/src/log_producer_config.h index 5eb281b..7d75cd6 100644 --- a/src/log_producer_config.h +++ b/src/log_producer_config.h @@ -95,7 +95,7 @@ typedef struct _log_producer_config char * logstore; char * accessKeyId; char * accessKey; - volatile char * stsToken; + char * stsToken; char * configName; char * topic; log_producer_config_tag * tags; diff --git a/src/log_producer_sender.c b/src/log_producer_sender.c index 1b238ed..41c423e 100644 --- a/src/log_producer_sender.c +++ b/src/log_producer_sender.c @@ -56,10 +56,11 @@ void * log_producer_send_fun(apr_thread_t * thread, void * param) } do { + void * stsTokenPtr = (void *)&config->stsToken; log_http_cont* cont = log_create_http_cont_with_lz4_data(config->endpoint, config->accessKeyId, config->accessKey, - (char *)apr_atomic_casptr((volatile void **)(&config->stsToken), NULL, NULL), + (char *)apr_atomic_casptr(stsTokenPtr, NULL, NULL), config->project, config->logstore, send_param->log_buf,