const int NumOfLogs = 5; /**< How many log files to rotate */
bool LogAllowDebugSet = false;
+#define S_TO_NS 1000000000UL
+#define S_TO_US 1000000UL
+#define US_TO_NS 1000UL
+
/**
* micro_elapsed - Number of microseconds between two timevals
* @param begin Begin time
if ((begin->tv_sec == 0) && (end->tv_sec != 0))
return LONG_MAX;
- return ((end->tv_sec - begin->tv_sec) * 1000000) + (end->tv_usec - begin->tv_usec);
+ return ((end->tv_sec - begin->tv_sec) * S_TO_US) +
+ (end->tv_usec - begin->tv_usec);
}
/**
* error_pause - Wait for an error message to be read
*
- * If a second hasn't elapsed since LastError, then wait.
+ * If '$sleep_time' seconds hasn't elapsed since LastError, then wait
*/
static void error_pause(void)
{
return;
}
+ unsigned long sleep = SleepTime * S_TO_NS;
long micro = micro_elapsed(&LastError, &now);
- if (micro >= 1000000)
+ if ((micro * US_TO_NS) >= sleep)
return;
- struct timespec wait = { 0 };
- wait.tv_nsec = 1000000000 - (micro * 10);
+ sleep -= (micro * US_TO_NS);
+
+ struct timespec wait = {
+ .tv_sec = (sleep / S_TO_NS),
+ .tv_nsec = (sleep % S_TO_NS),
+ };
mutt_refresh();
nanosleep(&wait, NULL);