Skip to content

Commit 2fd82e9

Browse files
Cheruvu.Sahithee.Vaibhav@ibm.comCheruvu.Sahithee.Vaibhav@ibm.com
authored andcommitted
out_azure_blob: address code rabbit comments 3
Signed-off-by: Cheruvu.Sahithee.Vaibhav@ibm.com <Cheruvu.Sahithee.Vaibhav@ibm.com>
1 parent 27acbc4 commit 2fd82e9

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

plugins/out_azure_blob/azure_blob.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ static int create_container(struct flb_azure_blob *ctx, char *name)
12471247
NULL, 0, NULL, 0, NULL, 0);
12481248
if (!c) {
12491249
flb_plg_error(ctx->ins, "cannot create HTTP client context");
1250+
flb_sds_destroy(uri);
12501251
flb_upstream_conn_release(u_conn);
12511252
return FLB_FALSE;
12521253
}
@@ -1346,6 +1347,7 @@ static int ensure_container(struct flb_azure_blob *ctx)
13461347
NULL, 0, NULL, 0, NULL, 0);
13471348
if (!c) {
13481349
flb_plg_error(ctx->ins, "cannot create HTTP client context");
1350+
flb_sds_destroy(uri);
13491351
flb_upstream_conn_release(u_conn);
13501352
return FLB_FALSE;
13511353
}
@@ -1435,14 +1437,17 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
14351437
/* validate 'total_file_size' */
14361438
if (ctx->file_size <= 0) {
14371439
flb_plg_error(ctx->ins, "Failed to parse upload_file_size");
1440+
azure_blob_store_exit(ctx);
14381441
return -1;
14391442
}
14401443
if (ctx->file_size < 1000000) {
14411444
flb_plg_error(ctx->ins, "upload_file_size must be at least 1MB");
1445+
azure_blob_store_exit(ctx);
14421446
return -1;
14431447
}
14441448
if (ctx->file_size > MAX_FILE_SIZE) {
14451449
flb_plg_error(ctx->ins, "Max total_file_size must be lower than %ld bytes", MAX_FILE_SIZE);
1450+
azure_blob_store_exit(ctx);
14461451
return -1;
14471452
}
14481453
ctx->has_old_buffers = azure_blob_store_has_data(ctx);
@@ -1456,6 +1461,9 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
14561461
ret = pthread_mutex_init(&ctx->token_mutex, NULL);
14571462
if (ret != 0) {
14581463
flb_plg_error(ctx->ins, "failed to initialize token mutex");
1464+
if (ctx->buffering_enabled == FLB_TRUE) {
1465+
azure_blob_store_exit(ctx);
1466+
}
14591467
flb_azure_blob_conf_destroy(ctx);
14601468
return -1;
14611469
}
@@ -1466,6 +1474,9 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
14661474
if (!token_url) {
14671475
flb_plg_error(ctx->ins, "failed to allocate token URL");
14681476
pthread_mutex_destroy(&ctx->token_mutex);
1477+
if (ctx->buffering_enabled == FLB_TRUE) {
1478+
azure_blob_store_exit(ctx);
1479+
}
14691480
flb_azure_blob_conf_destroy(ctx);
14701481
return -1;
14711482
}
@@ -1477,6 +1488,9 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
14771488
flb_plg_error(ctx->ins, "failed to build token URL");
14781489
flb_sds_destroy(token_url);
14791490
pthread_mutex_destroy(&ctx->token_mutex);
1491+
if (ctx->buffering_enabled == FLB_TRUE) {
1492+
azure_blob_store_exit(ctx);
1493+
}
14801494
flb_azure_blob_conf_destroy(ctx);
14811495
return -1;
14821496
}
@@ -1487,6 +1501,9 @@ static int cb_azure_blob_init(struct flb_output_instance *ins,
14871501
if (!ctx->o) {
14881502
flb_plg_error(ctx->ins, "failed to create OAuth2 context");
14891503
pthread_mutex_destroy(&ctx->token_mutex);
1504+
if (ctx->buffering_enabled == FLB_TRUE) {
1505+
azure_blob_store_exit(ctx);
1506+
}
14901507
flb_azure_blob_conf_destroy(ctx);
14911508
return -1;
14921509
}

0 commit comments

Comments
 (0)