diff options
author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-15 09:12:17 +0000 |
---|---|---|
committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-05-15 09:12:17 +0000 |
commit | f11bd43692bbd9c13e94cccad81eea4a92b7b06f (patch) | |
tree | fa3d1f7df063056e1f8115393bd5c6cdf04a91ae /src/zabbix_agent | |
parent | d9fe75cd26afc681a902a611d56454add751b113 (diff) | |
download | zabbix-f11bd43692bbd9c13e94cccad81eea4a92b7b06f.tar.gz zabbix-f11bd43692bbd9c13e94cccad81eea4a92b7b06f.tar.xz zabbix-f11bd43692bbd9c13e94cccad81eea4a92b7b06f.zip |
- fixed read loop in active.c. (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1773 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/zabbix_agent')
-rw-r--r-- | src/zabbix_agent/active.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/zabbix_agent/active.c b/src/zabbix_agent/active.c index ea014ab0..80998249 100644 --- a/src/zabbix_agent/active.c +++ b/src/zabbix_agent/active.c @@ -178,6 +178,7 @@ int get_active_checks(char *server, int port, char *error, int max_error_len) int s; int len; char c[MAX_BUF_LEN]; + char tmp[MAX_STRING_LEN]; struct hostent *hp; @@ -250,26 +251,30 @@ int get_active_checks(char *server, int port, char *error, int max_error_len) memset(c,0,MAX_BUF_LEN); zabbix_log(LOG_LEVEL_DEBUG, "Before read"); - len=read(s,c,MAX_BUF_LEN-1); - if(len == -1) + + while((len=read(s,tmp,MAX_BUF_LEN-1))>0) { - switch (errno) + if(len == -1) { - case EINTR: - zabbix_log( LOG_LEVEL_WARNING, "Timeout while receiving data from [%s]",server ); - snprintf(error,max_error_len-1,"Timeout while receiving data from [%s]",server); - break; - case ECONNRESET: - zabbix_log( LOG_LEVEL_WARNING, "Connection reset by peer."); - snprintf(error,max_error_len-1,"Connection reset by peer."); - close(s); - return NETWORK_ERROR; - default: - zabbix_log( LOG_LEVEL_WARNING, "Error while receiving data from [%s] [%s]",server, strerror(errno)); - snprintf(error,max_error_len-1,"Error while receiving data from [%s] [%s]",server, strerror(errno)); - } - close(s); - return FAIL; + switch (errno) + { + case EINTR: + zabbix_log( LOG_LEVEL_WARNING, "Timeout while receiving data from [%s]",server ); + snprintf(error,max_error_len-1,"Timeout while receiving data from [%s]",server); + break; + case ECONNRESET: + zabbix_log( LOG_LEVEL_WARNING, "Connection reset by peer."); + snprintf(error,max_error_len-1,"Connection reset by peer."); + close(s); + return NETWORK_ERROR; + default: + zabbix_log( LOG_LEVEL_WARNING, "Error while receiving data from [%s] [%s]",server, strerror(errno)); + snprintf(error,max_error_len-1,"Error while receiving data from [%s] [%s]",server, strerror(errno)); + } + close(s); + return FAIL; + } + strncat(c,tmp,MAX_BUF_LEN-1); } zabbix_log(LOG_LEVEL_DEBUG, "Read [%s]", c); |