git: f4bd2eeb661f - main - comms/usbmuxd: Workaround devd(8) race condition

From: Jason E. Hale <jhale_at_FreeBSD.org>
Date: Fri, 12 Jul 2024 06:24:40 UTC
The branch main has been updated by jhale:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f4bd2eeb661fd673294ee9a92b397b56b91ccde3

commit f4bd2eeb661fd673294ee9a92b397b56b91ccde3
Author:     Jason E. Hale <jhale@FreeBSD.org>
AuthorDate: 2024-07-11 22:36:26 +0000
Commit:     Jason E. Hale <jhale@FreeBSD.org>
CommitDate: 2024-07-12 06:24:35 +0000

    comms/usbmuxd: Workaround devd(8) race condition
    
    When connecting an Apple device via USB, the device connects, usbmuxd is
    started, then for reasons yet unknown, the device instantly disconnects,
    and reconnects.
    
    From dmesg when plugging in, for example:
    ugen0.5: <Apple Inc. iPhone> at usbus0
    <usbmuxd starts here>
    ugen0.5: <Apple Inc. iPhone> at usbus0 (disconnected)
    ugen0.5: <Apple Inc. iPhone> at usbus0
    
    Due to the disconnect, the instance of usbmuxd that is spawned when the
    device is first attached is subsequently killed by the unexplained
    detach because the cdce(4) devices have not yet been created, but not
    before the second instance of usbmuxd is started by the reattach. The
    second instance automatically exits because two instances cannot run
    simultaneously. The first instance then exits leaving no running
    instances.
    
    Adding a short sleep after the first instance is called to shutdown
    gives it enough time to completely exit before the second instance is
    spawned. Unfortunately, only one device is supported at a time until
    I can figure out why the hotplugging isn't working.
    
    While here, cleanup whitespace.
    
    PR:             280014
    Reported by:    <fabio.comolli@gmail.com>
---
 comms/usbmuxd/Makefile              |  1 +
 comms/usbmuxd/files/usbmuxd.conf.in | 12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/comms/usbmuxd/Makefile b/comms/usbmuxd/Makefile
index 92e22795e166..bff38d002dee 100644
--- a/comms/usbmuxd/Makefile
+++ b/comms/usbmuxd/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	usbmuxd
 DISTVERSION=	1.1.1-58
+PORTREVISION=	1
 DISTVERSIONSUFFIX=	-gbc0b91c
 CATEGORIES=	comms
 #MASTER_SITES=	https://github.com/libimobiledevice/${PORTNAME}/releases/download/${DISTVERSION}/
diff --git a/comms/usbmuxd/files/usbmuxd.conf.in b/comms/usbmuxd/files/usbmuxd.conf.in
index b0cd9685332e..62b79de65440 100644
--- a/comms/usbmuxd/files/usbmuxd.conf.in
+++ b/comms/usbmuxd/files/usbmuxd.conf.in
@@ -16,11 +16,11 @@ notify 100 {
 };
 
 notify 100 {
-        match "system"          "USB";
-        match "subsystem"       "DEVICE";
-        match "type"            "DETACH";
-        match "vendor"          "0x05ac";
-	match "product"         "(0x12[9a][0-9a-f]|0x8600)";
+	match "system"		"USB";
+	match "subsystem"	"DEVICE";
+	match "type"		"DETACH";
+	match "vendor"		"0x05ac";
+	match "product"		"(0x12[9a][0-9a-f]|0x8600)";
 	action "%%PREFIX%%/sbin/usbmuxd -x";
+	action "sleep 5";
 };
-