diff options
| author | Yaniv Kaul <ykaul@redhat.com> | 2018-07-09 13:32:26 +0300 | 
|---|---|---|
| committer | Amar Tumballi <amarts@redhat.com> | 2018-07-17 05:42:18 +0000 | 
| commit | 475826671a4bce7dada95e04cd9466d431e444e5 (patch) | |
| tree | 4c0192c0a579f1113d329e1fb0eabc6a434c962f | |
| parent | c02a25515aba085c7dfa2033f830760e7458301d (diff) | |
tier: Move time string formatting
There is no need to format the time, unless ret is true.
I don't think there's a reason to allocate memory for
those struct and char array unless we are formatting
either (But I'm not sure what the code convention is - are we
ok with 'local' variable declarations?)
Only compile-tested.
Change-Id: I9feb09871943764bd76bdfc9ac6ca506f329aac1
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
| -rw-r--r-- | xlators/cluster/dht/src/tier.c | 17 | 
1 files changed, 10 insertions, 7 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index e4294f4fda9..45a19d96243 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1690,22 +1690,16 @@ tier_migrate_files_using_qfile (migration_args_t *comp,          int ret                                 = -1;          tier_brick_list_t *local_brick          = NULL;          tier_brick_list_t *temp                 = NULL; -        char query_file_path_err[PATH_MAX]      = {0,}; -        struct tm tm                            = {0,};          gfdb_time_t current_time                = {0,}; -        char time_str[128]                      = {0,};          ssize_t qfile_array_size                = 0;          int count                               = 0;          int temp_fd                             = 0;          gf_tier_conf_t  *tier_conf              = NULL; -        int32_t len                             = 0;          tier_conf = &(query_cbk_args->defrag->tier_conf); -        /* Time format for error query files */ +        /* Time for error query files */          gettimeofday (¤t_time, NULL); -        gmtime_r (¤t_time.tv_sec, &tm); -        strftime (time_str, sizeof (time_str), "%F-%T", &tm);          /* Build the qfile list */          list_for_each_entry_safe (local_brick, temp, comp->brick_list, list) { @@ -1760,6 +1754,15 @@ out:          /* If there is an error rename all the query files to .err files           * with a timestamp for better debugging */          if (ret) { +                struct tm tm                            = {0,}; +                char time_str[128]                      = {0,}; +                char query_file_path_err[PATH_MAX]      = {0,}; +                int32_t len                             = 0; + +                /* Time format for error query files */ +                gmtime_r (¤t_time.tv_sec, &tm); +                strftime (time_str, sizeof (time_str), "%F-%T", &tm); +                  list_for_each_entry_safe (local_brick, temp, comp->brick_list,                                          list) {                          /* rename error qfile*/  | 
