summaryrefslogtreecommitdiffstats
path: root/src/usbmux.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-06-20 04:29:23 +0200
committerGravatar Nikias Bassen2009-06-20 04:29:23 +0200
commit94d700159d010176a57640d6f59476aaf43875fc (patch)
treee215eab15d5857b7eb7ef82deebee73cc3cbc1eb /src/usbmux.c
parentbb33ccdf06f261dca033d70772bc256c890c76f7 (diff)
downloadusbmuxd-94d700159d010176a57640d6f59476aaf43875fc.tar.gz
usbmuxd-94d700159d010176a57640d6f59476aaf43875fc.tar.bz2
hopefully fixed race condition on connection setup
Diffstat (limited to 'src/usbmux.c')
-rw-r--r--src/usbmux.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/usbmux.c b/src/usbmux.c
index 87cdede..927928e 100644
--- a/src/usbmux.c
+++ b/src/usbmux.c
@@ -100,6 +100,8 @@ struct usbmux_client_int {
100 int error; 100 int error;
101 101
102 int cleanup; 102 int cleanup;
103
104 int connected;
103}; 105};
104 106
105 107
@@ -734,6 +736,7 @@ int usbmux_new_client(usbmux_device_t device, uint16_t src_port,
734 add_connection(new_connection); 736 add_connection(new_connection);
735 new_connection->error = 0; 737 new_connection->error = 0;
736 new_connection->cleanup = 0; 738 new_connection->cleanup = 0;
739 new_connection->connected = 0;
737 hton_header(new_connection->header); 740 hton_header(new_connection->header);
738 log_debug_msg("%s: send_to_device (%d --> %d)\n", __func__, 741 log_debug_msg("%s: send_to_device (%d --> %d)\n", __func__,
739 ntohs(new_connection->header->sport), 742 ntohs(new_connection->header->sport),
@@ -931,6 +934,8 @@ uint32_t append_receive_buffer(usbmux_client_t client, char *packet)
931 sizeof(usbmux_tcp_header)) <= 0) { 934 sizeof(usbmux_tcp_header)) <= 0) {
932 log_debug_msg("%s: error when pushing to usb...\n", 935 log_debug_msg("%s: error when pushing to usb...\n",
933 __func__); 936 __func__);
937 } else {
938 client->connected = 1;
934 } 939 }
935 // need to revert some of the fields back to host notation. 940 // need to revert some of the fields back to host notation.
936 ntoh_header(client->header); 941 ntoh_header(client->header);
@@ -1253,3 +1258,11 @@ int usbmux_recv_timeout(usbmux_client_t client, char *data,
1253 1258
1254 return 0; 1259 return 0;
1255} 1260}
1261
1262int usbmux_is_connected(usbmux_client_t client)
1263{
1264 if (!client) {
1265 return 0;
1266 }
1267 return client->connected;
1268}