Commit 7b9e8681 authored by Jonathon Duerig's avatar Jonathon Duerig

Changed logging to log everything by default.

parent cfee4f04
......@@ -54,6 +54,10 @@ static void logPrefix(int flags)
{
fprintf(logFile, "ROBUST ");
}
if (flags & MAIN_LOOP)
{
fprintf(logFile, "MAIN_LOOP ");
}
if (logTimestamp)
{
struct timeval now;
......
......@@ -44,9 +44,10 @@ enum LOG_TYPE
SENSOR = 0x08,
CONNECTION_MODEL = 0x10,
ROBUST = 0x20,
MAIN_LOOP = 0x40,
// Shortcuts for common cases.
LOG_NOTHING = 0x00,
LOG_EVERYTHING = 0x3f
LOG_EVERYTHING = 0x7f
};
#endif
......@@ -156,6 +156,7 @@ void processArgs(int argc, char * argv[])
void init(void)
{
logInit(stderr, LOG_EVERYTHING, true);
srandom(getpid());
switch (global::connectionModelArg)
{
......@@ -186,19 +187,23 @@ void mainLoop(void)
{
fd_set readable = global::readers;
Time timeUntilWrite;
struct timeval * waitPeriod;
Time now = getCurrentTime();
multimap<Time, Connection *>::iterator nextWrite = schedule.begin();
if (nextWrite != schedule.end() && now < nextWrite->first)
{
timeUntilWrite = nextWrite->first - now;
waitPeriod = timeUntilWrite.getTimeval();
}
else
{
// otherwise we don't want to wait.
// otherwise we want to wait forever.
timeUntilWrite = Time();
waitPeriod = NULL;
}
logWrite(MAIN_LOOP, "Select");
int error = select(global::maxReader + 1, &readable, NULL, NULL,
timeUntilWrite.getTimeval());
waitPeriod);
if (error == -1)
{
switch (errno)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment