Skip to content

Commit 61525ba

Browse files
committed
Handle systems that don't have st_mtim.
Ignores nanoseconds, but it's checking for >1h old so a few nanoseconds shouldn't matter much. Fixes build on Mac OS X.
1 parent 27861e9 commit 61525ba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

misc-agent.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
270270
struct dirent *dp;
271271
struct stat sb;
272272
char *prefix = NULL, *dirpath, *path;
273-
struct timespec now, sub;
273+
struct timespec now, sub, *mtimp = NULL;
274274

275275
/* Only consider sockets last modified > 1 hour ago */
276276
if (clock_gettime(CLOCK_REALTIME, &now) != 0) {
@@ -309,7 +309,14 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
309309
}
310310
if (!S_ISSOCK(sb.st_mode))
311311
continue;
312-
if (timespeccmp(&sb.st_mtim, &now, >)) {
312+
#ifdef HAVE_STRUCT_STAT_ST_MTIM
313+
mtimp = &sb.st_mtim;
314+
#else
315+
sub.tv_sec = sb.st_mtime;
316+
sub.tv_nsec = 0;
317+
mtimp = ⊂
318+
#endif
319+
if (timespeccmp(mtimp, &now, >)) {
313320
debug3_f("Ignoring recent socket \"%s/%s\"",
314321
dirpath, dp->d_name);
315322
continue;

0 commit comments

Comments
 (0)