diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-03 18:13:54 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-03 18:13:54 +0000 |
commit | 73c9b25d2d0e40a657073489311a4ecd1643362c (patch) | |
tree | e7c695728d9c89504d140739422a9c7ef2fde8cc /cmd.c | |
parent | 743956edf898dceff67af785b7bda87cdbd3fdab (diff) | |
download | rtmux-73c9b25d2d0e40a657073489311a4ecd1643362c.tar.gz rtmux-73c9b25d2d0e40a657073489311a4ecd1643362c.tar.bz2 rtmux-73c9b25d2d0e40a657073489311a4ecd1643362c.zip |
It is too easy to create things in the same second; use a timespec instead.
Diffstat (limited to 'cmd.c')
-rw-r--r-- | cmd.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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) |