Skip to content

Commit

Permalink
[modify] refine ststoken switch
Browse files Browse the repository at this point in the history
  • Loading branch information
shabicheng committed Dec 13, 2017
1 parent 2ed19e9 commit 72167f9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/log_producer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/log_producer_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/log_producer_sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 72167f9

Please sign in to comment.