summaryrefslogtreecommitdiffstats
path: root/cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/cmd.c b/cmd.c
index 2fb90069..430a2410 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.39 2008-06-03 16:55:09 nicm Exp $ */
+/* $Id: cmd.c,v 1.40 2008-06-03 18:13:54 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -17,6 +17,7 @@
*/
#include <sys/types.h>
+#include <sys/time.h>
#include <fnmatch.h>
#include <getopt.h>
@@ -253,18 +254,18 @@ struct session *
cmd_lookup_session(const char *sname)
{
struct session *s, *newest = NULL;
- time_t tim;
+ struct timespec *ts;
u_int i;
- tim = 0;
+ ts = NULL;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL || fnmatch(sname, s->name, 0) != 0)
continue;
- if (s->tim > tim) {
+ if (ts == NULL || timespeccmp(&s->ts, ts, >)) {
newest = s;
- tim = s->tim;
+ ts = &s->ts;
}
}
@@ -305,7 +306,7 @@ cmd_find_session(struct cmd_ctx *ctx, const char *cname, const char *sname)
struct client *c;
struct msg_command_data *data = ctx->msgdata;
u_int i;
- time_t tim;
+ struct timespec *ts;
if (cname != NULL) {
if ((c = cmd_lookup_client(cname)) == NULL) {
@@ -342,12 +343,12 @@ cmd_find_session(struct cmd_ctx *ctx, const char *cname, const char *sname)
return (s);
}
- tim = 0;
+ ts = NULL;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
- if (s != NULL && s->tim > tim) {
+ if (s != NULL && (ts == NULL || timespeccmp(&s->ts, ts, >))) {
newest = ARRAY_ITEM(&sessions, i);
- tim = s->tim;
+ ts = &s->ts;
}
}
if (newest == NULL)