Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 631a630

Browse files
authored
Merge pull request #989 from IBM/mtimehandling
Handle mtime conversion conditioned on getstats success
2 parents a4a1e28 + 2bd4bdf commit 631a630

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bb/src/fh.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ int getActiveFileTransfers()
217217
{
218218
string prefix;
219219
struct stat statbuf;
220+
struct tm tmholder;
220221

221222
char mtime[256];
222223

@@ -228,8 +229,16 @@ int getActiveFileTransfers()
228229
prefix += string(".") + to_string(index) + string(".");
229230

230231
#define MKDATA(suffix, value) bberror << err( (prefix + string(suffix)).c_str(), value);
231-
fhentry.second->getstats(statbuf);
232-
strftime(mtime, sizeof(mtime), "%FT%TZ", gmtime(&statbuf.st_mtime));
232+
int l_getstats_rc = fhentry.second->getstats(statbuf);
233+
if (!l_getstats_rc ) {//zero return code
234+
struct tm * tmPTR = gmtime_r(&statbuf.st_mtime, &tmholder);
235+
if (tmPTR){
236+
strftime(mtime, sizeof(mtime), "%FT%TZ", tmPTR);
237+
}
238+
}
239+
else{
240+
strcpy(mtime,"UNKNOWN");
241+
}
233242

234243
MKDATA("name", fhentry.second->getfn());
235244
MKDATA("size", fhentry.second->getsize());

0 commit comments

Comments
 (0)