mirror of
https://github.com/SCST-project/scst.git
synced 2026-10-22 06:02:33 +00:00
scst: Use nanosleep for userspace polling delays
Retain the 50 ms and 100 ms polling intervals and the existing signal-interruption behavior while replacing the obsolete usleep interface. Cppcheck reports usleepCalled: Obsolescent function 'usleep' called. It is recommended to use 'nanosleep' or 'setitimer' instead.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <netdb.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "iscsid.h"
|
||||
|
||||
@@ -376,7 +377,7 @@ int target_del(u32 tid, u32 cookie)
|
||||
|
||||
/* We have not yet received session(s) removal event(s), so keep waiting */
|
||||
log_debug(1, "Target %d has sessions, keep waiting", tid);
|
||||
usleep(50000);
|
||||
nanosleep(&(const struct timespec){ .tv_nsec = 50000000 }, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <syslog.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
@@ -196,7 +197,7 @@ static int wait_until_finished(pid_t pid, unsigned long deadline, int *status, i
|
||||
}
|
||||
break;
|
||||
}
|
||||
usleep(100*1000);
|
||||
nanosleep(&(const struct timespec){ .tv_nsec = 100000000 }, NULL);
|
||||
time(&end);
|
||||
elapsed = difftime(end, start);
|
||||
} while (elapsed < deadline);
|
||||
|
||||
Reference in New Issue
Block a user