mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-13 06:01:03 +00:00
Cope with signals interrupting the nanosleep of nmsleep.
This commit is contained in:
parent
2ce7f28bbc
commit
bc0b14063f
13
util.c
13
util.c
@ -692,9 +692,14 @@ void thr_info_cancel(struct thr_info *thr)
|
||||
* on SMP machines */
|
||||
void nmsleep(unsigned int msecs)
|
||||
{
|
||||
struct timespec twait;
|
||||
struct timespec twait, tleft;
|
||||
int ret;
|
||||
|
||||
twait.tv_sec = msecs / 1000;
|
||||
twait.tv_nsec = (uint64_t)(msecs * 1000000) - (uint64_t)(twait.tv_sec / 1000000000);
|
||||
nanosleep(&twait, NULL);
|
||||
tleft.tv_sec = msecs / 1000;
|
||||
tleft.tv_nsec = (uint64_t)(msecs * 1000000) - (uint64_t)(twait.tv_sec / 1000000000);
|
||||
do {
|
||||
twait.tv_sec = tleft.tv_sec;
|
||||
twait.tv_nsec = tleft.tv_nsec;
|
||||
ret = nanosleep(&twait, &tleft);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user