[xiph-commits] r15610 - in icecast/trunk: log timing
karl at svn.xiph.org
karl at svn.xiph.org
Wed Jan 7 18:18:11 PST 2009
Author: karl
Date: 2009-01-07 18:18:11 -0800 (Wed, 07 Jan 2009)
New Revision: 15610
Modified:
icecast/trunk/log/log.c
icecast/trunk/log/log.h
icecast/trunk/timing/timing.c
Log:
log: When keeping around log lines, only allocate what we actually use. Allow
compiler printf arg checking.
timing: win32 fix, don't use timeGetTime, fixes access log timestamp
Modified: icecast/trunk/log/log.c
===================================================================
--- icecast/trunk/log/log.c 2009-01-07 22:51:06 UTC (rev 15609)
+++ icecast/trunk/log/log.c 2009-01-08 02:18:11 UTC (rev 15610)
@@ -360,17 +360,16 @@
static int create_log_entry (int log_id, const char *pre, const char *line)
{
- int len;
log_entry_t *entry;
if (loglist[log_id].keep_entries == 0)
return fprintf (loglist[log_id].logfile, "%s%s\n", pre, line);
entry = calloc (1, sizeof (log_entry_t));
- entry->line = malloc (LOG_MAXLINELEN);
- len = snprintf (entry->line, LOG_MAXLINELEN, "%s%s\n", pre, line);
- entry->len = len;
- loglist [log_id].total += len;
+ entry->len = strlen (pre) + strlen (line) + 2;
+ entry->line = malloc (entry->len);
+ snprintf (entry->line, entry->len, "%s%s\n", pre, line);
+ loglist [log_id].total += entry->len;
fprintf (loglist[log_id].logfile, "%s", entry->line);
*loglist [log_id].log_tail = entry;
@@ -386,7 +385,7 @@
}
else
loglist [log_id].entries++;
- return len;
+ return entry->len;
}
@@ -458,9 +457,9 @@
void log_write_direct(int log_id, const char *fmt, ...)
{
- char line[LOG_MAXLINELEN];
va_list ap;
time_t now;
+ char line[LOG_MAXLINELEN];
if (log_id < 0 || log_id >= LOG_MAXLOGS) return;
Modified: icecast/trunk/log/log.h
===================================================================
--- icecast/trunk/log/log.h 2009-01-07 22:51:06 UTC (rev 15609)
+++ icecast/trunk/log/log.h 2009-01-08 02:18:11 UTC (rev 15610)
@@ -39,6 +39,6 @@
void log_write(int log_id, unsigned priority, const char *cat, const char *func,
const char *fmt, ...);
-void log_write_direct(int log_id, const char *fmt, ...);
+void log_write_direct(int log_id, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
#endif /* __LOG_H__ */
Modified: icecast/trunk/timing/timing.c
===================================================================
--- icecast/trunk/timing/timing.c 2009-01-07 22:51:06 UTC (rev 15609)
+++ icecast/trunk/timing/timing.c 2009-01-08 02:18:11 UTC (rev 15610)
@@ -27,7 +27,7 @@
#include <sys/select.h>
#endif
-#ifdef __MINGW32__
+#ifdef HAVE_SYS_TIMEB_H
#include <sys/timeb.h>
#endif
@@ -40,22 +40,20 @@
*/
uint64_t timing_get_time(void)
{
-#ifdef _WIN32
-#ifdef __MINGW32__
+#ifdef HAVE_GETTIMEOFDAY
+ struct timeval mtv;
+
+ gettimeofday(&mtv, NULL);
+
+ return (uint64_t)(mtv.tv_sec) * 1000 + (uint64_t)(mtv.tv_usec) / 1000;
+#elif HAVE_FTIME
struct timeb t;
ftime(&t);
return t.time * 1000 + t.millitm;
#else
- return timeGetTime();
+#error need time query handler
#endif
-#else
- struct timeval mtv;
-
- gettimeofday(&mtv, NULL);
-
- return (uint64_t)(mtv.tv_sec) * 1000 + (uint64_t)(mtv.tv_usec) / 1000;
-#endif
}
void timing_sleep(uint64_t sleeptime)
More information about the commits
mailing list