From f0eb88af144d6d490e2d54ce50e3c095dfcea5c2 Mon Sep 17 00:00:00 2001 From: Christopher Ramey Date: Wed, 4 Feb 2015 20:59:29 +0000 Subject: [PATCH] Changed filename to use microseconds in file name to exclude overlap in high-connect count events --- src/wstationd.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/wstationd.c b/src/wstationd.c index 925ef0f..7b9d4cc 100644 --- a/src/wstationd.c +++ b/src/wstationd.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -180,16 +181,18 @@ int main(int argc, char *argv[]) // Collect the time of the connection, process it into // a short string - time_t timeraw = time(NULL); - struct tm* timeptr = localtime(&timeraw); - char timebuff[15]; - strftime(&timebuff[0], 15, "%Y%m%d%H%M%S", timeptr); + struct timeval tvtime; + gettimeofday(&tvtime, NULL); + struct tm* timeptr = localtime(&tvtime.tv_sec); + char timebuff[20]; + strftime(&timebuff[0], 20, "%Y%m%d%H%M%S", timeptr); // Take the short date/time connection string and add the client address // to create a filename - char fnbuff[35]; - snprintf(&fnbuff[0], 34, "%s-%s.dat", - timebuff, inet_ntoa(client.sin_addr) + char fnbuff[50]; + snprintf(&fnbuff[0], 50, "%s.%ld-%s.dat", + timebuff, tvtime.tv_usec, + inet_ntoa(client.sin_addr) ); // Open a file to dump our data to