From 8c6eef637625edae6104dd7ff8d9fabc8d00475f Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 28 Apr 2004 13:40:58 +0000 Subject: Give udev some time to create the RFCOMM device nodes --- dund/dun.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dund/dun.c b/dund/dun.c index 1486d515..6611ad86 100644 --- a/dund/dun.c +++ b/dund/dun.c @@ -182,7 +182,7 @@ static int dun_create_tty(int sk, char *tty, int size) { struct sockaddr_rc sa; struct stat st; - int id, alen; + int id, alen, try = 3; struct rfcomm_dev_req req = { flags: (1 << RFCOMM_REUSE_DLC) | (1 << RFCOMM_RELEASE_ONHUP), @@ -205,10 +205,19 @@ static int dun_create_tty(int sk, char *tty, int size) return id; snprintf(tty, size, "/dev/rfcomm%d", id); - if (stat(tty, &st) < 0) { + while (stat(tty, &st) < 0) { snprintf(tty, size, "/dev/bluetooth/rfcomm/%d", id); if (stat(tty, &st) < 0) { snprintf(tty, size, "/dev/rfcomm%d", id); + if (try--) { + sleep(1); + continue; + } + + memset(&req, 0, sizeof(req)); + req.dev_id = id; + ioctl(sk, RFCOMMRELEASEDEV, &req); + return -1; } } -- cgit