diff mbox series

[OpenWrt-Devel] rpcd: Switch to nanosleep

Message ID 20190718175444.475-1-rosenp@gmail.com
State Accepted
Headers show
Series [OpenWrt-Devel] rpcd: Switch to nanosleep | expand

Commit Message

Rosen Penev July 18, 2019, 5:54 p.m. UTC
usleep has been deprecated by POSIX.1-2001 and removed in POSIX.1-2008.
Fixes compilation when libc does not include usleep (optional with
uClibc-ng).

nanosleep also has the advantage of being more accurate.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 sys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jo-Philipp Wich Sept. 3, 2019, 9:26 a.m. UTC | #1
Merged into project/rpcd.git, branch master.
Thank you!
diff mbox series

Patch

diff --git a/sys.c b/sys.c
index 43eadc4..2d83522 100644
--- a/sys.c
+++ b/sys.c
@@ -145,7 +145,8 @@  rpc_cgi_password_set(struct ubus_context *ctx, struct ubus_object *obj,
 		if (n < 0)
 			return rpc_errno_status();
 
-		usleep(100 * 1000);
+		const struct timespec req = {0, 100 * 1000 * 1000};
+		nanosleep(&req, NULL);
 
 		n = write(fds[1], blobmsg_data(tb[RPC_P_PASSWORD]),
 		              blobmsg_data_len(tb[RPC_P_PASSWORD]) - 1);