summaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
authorSaya Sugiura <ssugiura@jp.adit-jv.com>2019-01-08 16:45:04 +0900
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2019-05-06 15:55:01 +0900
commitdf6fc2a1ce9f3a1778e9c8e14c800cd2ad96e96e (patch)
tree6356575d4f9e6461769f7b40b72829366feb37b4 /src/console
parent4fe69b0927f4c5d0cb3b3ae4fa64500db22b13d0 (diff)
downloadDLT-daemon-df6fc2a1ce9f3a1778e9c8e14c800cd2ad96e96e.tar.gz
POSIX: Replace usleep with nanosleep
Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
Diffstat (limited to 'src/console')
-rw-r--r--src/console/dlt-control-common.h3
-rw-r--r--src/console/dlt-control.c5
-rw-r--r--src/console/logstorage/dlt-logstorage-udev.c5
3 files changed, 11 insertions, 2 deletions
diff --git a/src/console/dlt-control-common.h b/src/console/dlt-control-common.h
index 0bd7deb..f2dc38f 100644
--- a/src/console/dlt-control-common.h
+++ b/src/console/dlt-control-common.h
@@ -50,6 +50,9 @@
#define DLT_CTRL_DEFAULT_ECUID "ECU1"
+#define NANOSEC_PER_MILLISEC 1000000
+#define NANOSEC_PER_SEC 1000000000
+
/* To be used as Dlt Message body when sending to DLT daemon */
typedef struct
{
diff --git a/src/console/dlt-control.c b/src/console/dlt-control.c
index a1eb408..19e4b36 100644
--- a/src/console/dlt-control.c
+++ b/src/console/dlt-control.c
@@ -232,6 +232,7 @@ int main(int argc, char *argv[])
int c;
int index;
char *endptr = NULL;
+ struct timespec ts;
/* Initialize dltdata */
dltdata.vflag = 0;
@@ -641,7 +642,9 @@ int main(int argc, char *argv[])
/*dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag); */
/* Wait timeout */
- usleep(dltdata.tvalue * 1000);
+ ts.tv_sec = (dltdata.tvalue * NANOSEC_PER_MILLISEC) / NANOSEC_PER_SEC;
+ ts.tv_nsec = (dltdata.tvalue * NANOSEC_PER_MILLISEC) % NANOSEC_PER_SEC;
+ nanosleep(&ts, NULL);
}
/* Dlt Client Cleanup */
diff --git a/src/console/logstorage/dlt-logstorage-udev.c b/src/console/logstorage/dlt-logstorage-udev.c
index 578f1fa..e50e660 100644
--- a/src/console/logstorage/dlt-logstorage-udev.c
+++ b/src/console/logstorage/dlt-logstorage-udev.c
@@ -207,6 +207,7 @@ static int logstorage_udev_udevd_callback(void)
DltLogstorageCtrl *lctrl = get_logstorage_control();
LogstorageCtrlUdev *prvt = NULL;
struct udev_device *partition = NULL;
+ struct timespec ts;
if (!lctrl) {
pr_error("Not able to get logstorage control instance.\n");
@@ -247,7 +248,9 @@ static int logstorage_udev_udevd_callback(void)
* Then, udev is only interesting to simplify the check on new devices,
* and/or for hot unplug (without unmount).
*/
- usleep(500 * 1000);
+ ts.tv_sec = 0;
+ ts.tv_nsec = 500 * NANOSEC_PER_MILLISEC;
+ nanosleep(&ts, NULL);
ret = check_mountpoint_from_partition(EVENT_MOUNTED, partition);
}
else if (strncmp(action, "remove", sizeof("remove")) == 0)