diff options
| author | 2019-06-16 01:25:12 +0200 | |
|---|---|---|
| committer | 2019-06-16 01:25:12 +0200 | |
| commit | 7a0ab5f8f25b1c7f0c7313d7feda9c41c8058702 (patch) | |
| tree | 77bf5af2a551d44536089dbf3aa26227283f3c36 | |
| parent | fa1c5a9029b321adc2597bbe76920e5a7efd785b (diff) | |
| download | libimobiledevice-7a0ab5f8f25b1c7f0c7313d7feda9c41c8058702.tar.gz libimobiledevice-7a0ab5f8f25b1c7f0c7313d7feda9c41c8058702.tar.bz2 | |
syslog_relay: Fix timeout issue introduced with recent libusbmuxd commit ca245709
| -rw-r--r-- | include/libimobiledevice/syslog_relay.h | 12 | ||||
| -rw-r--r-- | src/syslog_relay.c | 8 |
2 files changed, 13 insertions, 7 deletions
diff --git a/include/libimobiledevice/syslog_relay.h b/include/libimobiledevice/syslog_relay.h index 0080b54..ea7b649 100644 --- a/include/libimobiledevice/syslog_relay.h +++ b/include/libimobiledevice/syslog_relay.h | |||
| @@ -34,11 +34,13 @@ extern "C" { | |||
| 34 | 34 | ||
| 35 | /** Error Codes */ | 35 | /** Error Codes */ |
| 36 | typedef enum { | 36 | typedef enum { |
| 37 | SYSLOG_RELAY_E_SUCCESS = 0, | 37 | SYSLOG_RELAY_E_SUCCESS = 0, |
| 38 | SYSLOG_RELAY_E_INVALID_ARG = -1, | 38 | SYSLOG_RELAY_E_INVALID_ARG = -1, |
| 39 | SYSLOG_RELAY_E_MUX_ERROR = -2, | 39 | SYSLOG_RELAY_E_MUX_ERROR = -2, |
| 40 | SYSLOG_RELAY_E_SSL_ERROR = -3, | 40 | SYSLOG_RELAY_E_SSL_ERROR = -3, |
| 41 | SYSLOG_RELAY_E_UNKNOWN_ERROR = -256 | 41 | SYSLOG_RELAY_E_NOT_ENOUGH_DATA = -4, |
| 42 | SYSLOG_RELAY_E_TIMEOUT = -5, | ||
| 43 | SYSLOG_RELAY_E_UNKNOWN_ERROR = -256 | ||
| 42 | } syslog_relay_error_t; | 44 | } syslog_relay_error_t; |
| 43 | 45 | ||
| 44 | typedef struct syslog_relay_client_private syslog_relay_client_private; | 46 | typedef struct syslog_relay_client_private syslog_relay_client_private; |
diff --git a/src/syslog_relay.c b/src/syslog_relay.c index 3be84e0..0d71392 100644 --- a/src/syslog_relay.c +++ b/src/syslog_relay.c | |||
| @@ -55,6 +55,10 @@ static syslog_relay_error_t syslog_relay_error(service_error_t err) | |||
| 55 | return SYSLOG_RELAY_E_MUX_ERROR; | 55 | return SYSLOG_RELAY_E_MUX_ERROR; |
| 56 | case SERVICE_E_SSL_ERROR: | 56 | case SERVICE_E_SSL_ERROR: |
| 57 | return SYSLOG_RELAY_E_SSL_ERROR; | 57 | return SYSLOG_RELAY_E_SSL_ERROR; |
| 58 | case SERVICE_E_NOT_ENOUGH_DATA: | ||
| 59 | return SYSLOG_RELAY_E_NOT_ENOUGH_DATA; | ||
| 60 | case SERVICE_E_TIMEOUT: | ||
| 61 | return SYSLOG_RELAY_E_TIMEOUT; | ||
| 58 | default: | 62 | default: |
| 59 | break; | 63 | break; |
| 60 | } | 64 | } |
| @@ -129,7 +133,7 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive_with_timeout(sysl | |||
| 129 | } | 133 | } |
| 130 | 134 | ||
| 131 | res = syslog_relay_error(service_receive_with_timeout(client->parent, data, size, (uint32_t*)&bytes, timeout)); | 135 | res = syslog_relay_error(service_receive_with_timeout(client->parent, data, size, (uint32_t*)&bytes, timeout)); |
| 132 | if (bytes <= 0) { | 136 | if (res != SYSLOG_RELAY_E_SUCCESS && res != SYSLOG_RELAY_E_TIMEOUT && res != SYSLOG_RELAY_E_NOT_ENOUGH_DATA) { |
| 133 | debug_info("Could not read data, error %d", res); | 137 | debug_info("Could not read data, error %d", res); |
| 134 | } | 138 | } |
| 135 | if (received) { | 139 | if (received) { |
| @@ -153,7 +157,7 @@ void *syslog_relay_worker(void *arg) | |||
| 153 | char c; | 157 | char c; |
| 154 | uint32_t bytes = 0; | 158 | uint32_t bytes = 0; |
| 155 | ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); | 159 | ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); |
| 156 | if ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS)) { | 160 | if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) { |
| 157 | continue; | 161 | continue; |
| 158 | } else if (ret < 0) { | 162 | } else if (ret < 0) { |
| 159 | debug_info("Connection to syslog relay interrupted"); | 163 | debug_info("Connection to syslog relay interrupted"); |
