Commit 42a139cf authored by 's avatar

fd #0 is valid so it must be closed too


git-svn-id: file:///home/svn/mapi/trunk@1391 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent d1fe2340
......@@ -543,7 +543,7 @@ void connect_hosts() { // {{{
if(!host[h].enabled) host[h].fd = -1;
if(host[h].enabled && !host[h].connected && !mapi_is_sensor_down(host[h].fd)) {
if(host[h].fd > 0) { // probably forced reconnection, try to close first
if(host[h].fd != -1) { // probably forced reconnection, try to close first
fprintf(stdout, "packetloss: close flow to %s\n", host[h].name); fflush(stdout);
if (mapi_close_flow(host[h].fd) < 0) {
fprintf(stderr, "packetloss: Close flow failed\n");
......@@ -1022,6 +1022,7 @@ int main(int argc, char *argv[]) {
host[h].netload_stats_dev = (struct tstatistics *) getcmem(host[h].devices, sizeof(struct tstatistics));
host[h].flowsstats_dev = (struct flows_stat *) getcmem(host[h].devices, sizeof(struct flows_stat));
host[h].flowsstats_total_dev = (struct flows_stat_total *) getcmem(host[h].devices, sizeof(struct flows_stat_total));
host[h].fd = -1;
}
// }}}
......@@ -1147,11 +1148,13 @@ int main(int argc, char *argv[]) {
// Read expired_flows results from hosts {{{
for (h = 0; h < hosts; h++) {
if(mapi_is_sensor_down(host[h].fd)) host[h].connected = 0;
if(host[h].connected) {
state(S_MAPI_READ_RESULTS, host[h].name);
if((host[h].results_dev = (mapi_results_t *) mapi_read_results(host[h].fd, host[h].fid_loss)) == NULL) host[h].connected = 0;
if((host[h].results_netload_dev = (mapi_results_t *) mapi_read_results(host[h].fd, host[h].fid_load)) == NULL) host[h].connected = 0;
if(host[h].enabled && host[h].connected && host[h].fd != -1) {
if(mapi_is_sensor_down(host[h].fd)) host[h].connected = 0;
if(host[h].connected) {
state(S_MAPI_READ_RESULTS, host[h].name);
if((host[h].results_dev = (mapi_results_t *) mapi_read_results(host[h].fd, host[h].fid_loss)) == NULL) host[h].connected = 0;
if((host[h].results_netload_dev = (mapi_results_t *) mapi_read_results(host[h].fd, host[h].fid_load)) == NULL) host[h].connected = 0;
}
}
}
// }}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment