diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2004-04-28 13:40:58 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2004-04-28 13:40:58 +0000 |
commit | 8c6eef637625edae6104dd7ff8d9fabc8d00475f (patch) | |
tree | 7d389db7c39f026da7b2e3b2caefb86117e4b865 /dund | |
parent | b8707600fd45e0cda31654fc7b2932f29b28d1a1 (diff) |
Give udev some time to create the RFCOMM device nodes
Diffstat (limited to 'dund')
-rw-r--r-- | dund/dun.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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; } } |