/* Queue: pairing */ static void try_pairing(void) { struct remote_info *ri; for (ri = remote_list; ri; ri = ri->next) { /* We've got both the mDNS data and the pin */ if (ri->paircode && ri->pin) { unlink_remote(ri); do_pairing(ri); } } }
/* Thread: main (pairing) */ static void pairing_cb(int fd, short event, void *arg) { struct remote_info *ri; #ifdef USE_EVENTFD eventfd_t count; int ret; ret = eventfd_read(pairing_efd, &count); if (ret < 0) { DPRINTF(E_LOG, L_REMOTE, "Could not read event counter: %s\n", strerror(errno)); return; } #else int dummy; /* Drain the pipe */ while (read(pairing_pipe[0], &dummy, sizeof(dummy)) >= 0) ; /* EMPTY */ #endif for (;;) { pthread_mutex_lock(&remote_lck); for (ri = remote_list; ri; ri = ri->next) { /* We've got both the mDNS data and the pin */ if (ri->paircode && ri->pin) { unlink_remote(ri); break; } } pthread_mutex_unlock(&remote_lck); if (!ri) break; do_pairing(ri); } event_add(&pairingev, NULL); }