Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try not to show infinite error dialogs #212

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Try not to show infinite error dialogs
pde committed Jan 22, 2022
commit c30cb8508c709fef014368289dac059175ab0120
11 changes: 9 additions & 2 deletions src/usb.c
Original file line number Diff line number Diff line change
@@ -84,14 +84,20 @@ int CheckAdbDevices(int port) {
return rc;
}

int ever_worked = 0;
int error_shown = 0;

int CheckiOSDevices(int port) {
usbmuxd_device_info_t *deviceList = NULL;
const int deviceCount = usbmuxd_get_device_list(&deviceList);
dbgprint("CheckiOSDevices: found %d devices\n", deviceCount);

if (deviceCount < 0) {
MSG_ERROR("Error loading devices.\n"
"Make sure usbmuxd service is installed and running.");
if (!error_shown && !ever_worked) {
MSG_ERROR("Error loading devices.\n"
"Make sure usbmuxd service is installed and running.");
error_shown = 0;
}
return ERROR_LOADING_DEVICES;
}
if (deviceCount == 0) {
@@ -109,6 +115,7 @@ int CheckiOSDevices(int port) {
return ERROR_ADDING_FORWARD;
}

ever_worked = 1;
// remove the NONBLOCK flag
int flags = fcntl(sfd, F_GETFL, NULL);
flags &= ~O_NONBLOCK;