diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 15 |
1 files changed, 9 insertions, 6 deletions
| @@ -34,8 +34,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
| 34 | 34 | ||
| 35 | #include "log.h" | 35 | #include "log.h" |
| 36 | #include "usb.h" | 36 | #include "usb.h" |
| 37 | #include "device.h" | ||
| 37 | 38 | ||
| 38 | const char *socket_path = "/tmp/usbmuxd"; //TODO: CHANGEME | 39 | static const char *socket_path = "/tmp/usbmuxd"; //TODO: CHANGEME |
| 39 | 40 | ||
| 40 | int create_socket(void) { | 41 | int create_socket(void) { |
| 41 | struct sockaddr_un bind_addr; | 42 | struct sockaddr_un bind_addr; |
| @@ -75,17 +76,17 @@ int main_loop(int listenfd) | |||
| 75 | struct fdlist pollfds; | 76 | struct fdlist pollfds; |
| 76 | 77 | ||
| 77 | while(1) { | 78 | while(1) { |
| 78 | usbmuxd_log(LL_SPEW, "main_loop iteration"); | 79 | usbmuxd_log(LL_FLOOD, "main_loop iteration"); |
| 79 | to = usb_get_timeout(); | 80 | to = usb_get_timeout(); |
| 80 | usbmuxd_log(LL_SPEW, "USB timeout is %d ms", to); | 81 | usbmuxd_log(LL_FLOOD, "USB timeout is %d ms", to); |
| 81 | 82 | ||
| 82 | fdlist_create(&pollfds); | 83 | fdlist_create(&pollfds); |
| 83 | fdlist_add(&pollfds, FD_LISTEN, listenfd, POLLIN); | 84 | fdlist_add(&pollfds, FD_LISTEN, listenfd, POLLIN); |
| 84 | usb_get_fds(&pollfds); | 85 | usb_get_fds(&pollfds); |
| 85 | usbmuxd_log(LL_SPEW, "fd count is %d", pollfds.count); | 86 | usbmuxd_log(LL_FLOOD, "fd count is %d", pollfds.count); |
| 86 | 87 | ||
| 87 | cnt = poll(pollfds.fds, pollfds.count, to); | 88 | cnt = poll(pollfds.fds, pollfds.count, to); |
| 88 | usbmuxd_log(LL_SPEW, "poll() returned %d", cnt); | 89 | usbmuxd_log(LL_FLOOD, "poll() returned %d", cnt); |
| 89 | 90 | ||
| 90 | if(cnt == 0) { | 91 | if(cnt == 0) { |
| 91 | if(usb_process() < 0) { | 92 | if(usb_process() < 0) { |
| @@ -122,6 +123,7 @@ int main(int argc, char *argv[]) | |||
| 122 | if(listenfd < 0) | 123 | if(listenfd < 0) |
| 123 | return 1; | 124 | return 1; |
| 124 | 125 | ||
| 126 | device_init(); | ||
| 125 | usbmuxd_log(LL_INFO, "Initializing USB"); | 127 | usbmuxd_log(LL_INFO, "Initializing USB"); |
| 126 | if((res = usb_init()) < 0) | 128 | if((res = usb_init()) < 0) |
| 127 | return 2; | 129 | return 2; |
| @@ -135,8 +137,9 @@ int main(int argc, char *argv[]) | |||
| 135 | 137 | ||
| 136 | usbmuxd_log(LL_NOTICE, "usbmux shutting down"); | 138 | usbmuxd_log(LL_NOTICE, "usbmux shutting down"); |
| 137 | usb_shutdown(); | 139 | usb_shutdown(); |
| 140 | device_shutdown(); | ||
| 138 | usbmuxd_log(LL_NOTICE, "Shutdown complete"); | 141 | usbmuxd_log(LL_NOTICE, "Shutdown complete"); |
| 139 | 142 | ||
| 140 | if(res < 0) | 143 | if(res < 0) |
| 141 | return -res; | 144 | return -res; |
| 142 | return 0; | 145 | return 0; |
