diff options
-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" { /** Error Codes */ typedef enum { - SYSLOG_RELAY_E_SUCCESS = 0, - SYSLOG_RELAY_E_INVALID_ARG = -1, - SYSLOG_RELAY_E_MUX_ERROR = -2, - SYSLOG_RELAY_E_SSL_ERROR = -3, - SYSLOG_RELAY_E_UNKNOWN_ERROR = -256 + SYSLOG_RELAY_E_SUCCESS = 0, + SYSLOG_RELAY_E_INVALID_ARG = -1, + SYSLOG_RELAY_E_MUX_ERROR = -2, + SYSLOG_RELAY_E_SSL_ERROR = -3, + SYSLOG_RELAY_E_NOT_ENOUGH_DATA = -4, + SYSLOG_RELAY_E_TIMEOUT = -5, + SYSLOG_RELAY_E_UNKNOWN_ERROR = -256 } syslog_relay_error_t; 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) return SYSLOG_RELAY_E_MUX_ERROR; case SERVICE_E_SSL_ERROR: return SYSLOG_RELAY_E_SSL_ERROR; + case SERVICE_E_NOT_ENOUGH_DATA: + return SYSLOG_RELAY_E_NOT_ENOUGH_DATA; + case SERVICE_E_TIMEOUT: + return SYSLOG_RELAY_E_TIMEOUT; default: break; } @@ -129,7 +133,7 @@ LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive_with_timeout(sysl } res = syslog_relay_error(service_receive_with_timeout(client->parent, data, size, (uint32_t*)&bytes, timeout)); - if (bytes <= 0) { + if (res != SYSLOG_RELAY_E_SUCCESS && res != SYSLOG_RELAY_E_TIMEOUT && res != SYSLOG_RELAY_E_NOT_ENOUGH_DATA) { debug_info("Could not read data, error %d", res); } if (received) { @@ -153,7 +157,7 @@ void *syslog_relay_worker(void *arg) char c; uint32_t bytes = 0; ret = syslog_relay_receive_with_timeout(srwt->client, &c, 1, &bytes, 100); - if ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS)) { + if (ret == SYSLOG_RELAY_E_TIMEOUT || ret == SYSLOG_RELAY_E_NOT_ENOUGH_DATA || ((bytes == 0) && (ret == SYSLOG_RELAY_E_SUCCESS))) { continue; } else if (ret < 0) { debug_info("Connection to syslog relay interrupted"); |