2006-01-07 02:29:09 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* Busybox utility routines.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Tito Ragusa <tito-wolit@tiscali.it>
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2006-01-07 02:29:09 +05:30
|
|
|
*/
|
2006-04-03 22:09:31 +05:30
|
|
|
#include "libbb.h"
|
2006-01-07 02:29:09 +05:30
|
|
|
|
2020-11-29 17:10:25 +05:30
|
|
|
/* void FAST_FUNC bb_do_delay(unsigned seconds) { ... } - no users yet */
|
2020-11-29 16:02:48 +05:30
|
|
|
|
|
|
|
#ifndef LOGIN_FAIL_DELAY
|
|
|
|
#define LOGIN_FAIL_DELAY 3
|
|
|
|
#endif
|
|
|
|
void FAST_FUNC pause_after_failed_login(void)
|
2006-01-07 02:29:09 +05:30
|
|
|
{
|
2020-11-29 16:02:48 +05:30
|
|
|
#if 0 /* over-engineered madness */
|
|
|
|
time_t end, diff;
|
2006-01-07 02:29:09 +05:30
|
|
|
|
2020-11-29 16:02:48 +05:30
|
|
|
end = time(NULL) + LOGIN_FAIL_DELAY;
|
|
|
|
diff = LOGIN_FAIL_DELAY;
|
2009-10-27 14:24:34 +05:30
|
|
|
do {
|
2020-11-29 16:02:48 +05:30
|
|
|
sleep(diff);
|
|
|
|
diff = end - time(NULL);
|
|
|
|
} while (diff > 0);
|
|
|
|
#else
|
|
|
|
sleep(LOGIN_FAIL_DELAY);
|
|
|
|
#endif
|
2006-01-07 02:29:09 +05:30
|
|
|
}
|
2020-11-29 16:07:34 +05:30
|
|
|
|
|
|
|
void FAST_FUNC sleep1(void)
|
|
|
|
{
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
2020-11-29 17:10:25 +05:30
|
|
|
void FAST_FUNC msleep(unsigned ms)
|
|
|
|
{
|
|
|
|
/* 1. usleep(n) is not guaranteed by standards to accept n >= 1000000
|
|
|
|
* 2. multiplication in usleep(ms * 1000) can overflow if ms > 4294967
|
|
|
|
* (sleep of ~71.5 minutes)
|
|
|
|
* Let's play safe and loop:
|
|
|
|
*/
|
|
|
|
while (ms > 500) {
|
|
|
|
usleep(500000);
|
|
|
|
ms -= 500;
|
|
|
|
}
|
|
|
|
usleep(ms * 1000);
|
|
|
|
}
|