From e7125356421449de4614aca24446f1d198aa9b3b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 26 Oct 2014 11:36:35 +0100 Subject: [PATCH 1/1] command.c: Replace usleep() by nanosleep(). POSIX.1-2001 declares usleep() obsolete and POSIX.1-2008 removes the specification. Fortunately, there is only a single user of usleep() in the tree: com_sender() which needs to retry the command if another sender command is currently running. This commit changes com_sender() to call nanosleep() instead of usleep() and adds a comment which explains why we are going to sleep at this point. --- command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/command.c b/command.c index db28b39d..09c1b781 100644 --- a/command.c +++ b/command.c @@ -363,8 +363,10 @@ static int com_sender(struct command_context *cc) for (i = 0; i < 10; i++) { mutex_lock(mmd_mutex); if (mmd->sender_cmd_data.cmd_num >= 0) { + /* another sender command is active, retry in 100ms */ + struct timespec ts = {.tv_nsec = 100 * 1000 * 1000}; mutex_unlock(mmd_mutex); - usleep(100 * 1000); + nanosleep(&ts, NULL); continue; } mmd->sender_cmd_data = scd; -- 2.30.2