Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2009-12-14 22:43:14 +0000
committereutarass2009-12-14 22:43:14 +0000
commit6f8e7710a564f930dab396f59d28b57aa7219fcd (patch)
tree1d44884d9f3011b504e0c153ef318b47fd44850b
parentb8f7f198187d114fcf53cdd9cb1f0602429348e3 (diff)
downloadorg.eclipse.tcf.agent-6f8e7710a564f930dab396f59d28b57aa7219fcd.tar.gz
org.eclipse.tcf.agent-6f8e7710a564f930dab396f59d28b57aa7219fcd.tar.xz
org.eclipse.tcf.agent-6f8e7710a564f930dab396f59d28b57aa7219fcd.zip
TCF Agent: fixed: when network interface is disabled or changes IP address, the agent does not remove stale entries from peers table
-rw-r--r--framework/peer.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/framework/peer.c b/framework/peer.c
index 9d308c22..fe20e602 100644
--- a/framework/peer.c
+++ b/framework/peer.c
@@ -24,10 +24,9 @@
#include "peer.h"
#include "myalloc.h"
#include "events.h"
+#include "protocol.h"
#include "trace.h"
-#define STALE_CHECK_TIME 20
-
typedef struct PeersListener {
peer_server_listener fnp;
void * arg;
@@ -80,10 +79,7 @@ static void clear_stale_peers(void * x) {
assert(is_dispatch_thread());
while ((s = *sp) != NULL) {
- if (s->flags & PS_FLAG_LOCAL) {
- sp = &s->next;
- }
- else if (s->expiration_time <= timenow) {
+ if (s->expiration_time <= timenow) {
/* Delete stale entry */
*sp = s->next;
notify_listeners(s, PS_EVENT_REMOVED);
@@ -95,7 +91,7 @@ static void clear_stale_peers(void * x) {
}
}
if (keep_timer) {
- post_event_with_delay(clear_stale_peers, NULL, STALE_CHECK_TIME * 1000000);
+ post_event_with_delay(clear_stale_peers, NULL, PEER_DATA_REFRESH_PERIOD * 1000000);
}
else {
stale_timer_active = 0;
@@ -167,8 +163,7 @@ PeerServer * peer_server_add(PeerServer * n, unsigned int stale_delta) {
if (strcmp(s->id, n->id) == 0) {
if ((s->flags & PS_FLAG_LOCAL) && !(n->flags & PS_FLAG_LOCAL) || is_same(s, n)) {
/* Never replace local entries with discovered ones */
- s->creation_time = time(NULL);
- s->expiration_time = s->creation_time + stale_delta;
+ s->expiration_time = time(NULL) + stale_delta;
if (!(s->flags & PS_FLAG_LOCAL)) s->flags = n->flags;
peer_server_free(n);
notify_listeners(s, PS_EVENT_HEART_BEAT);
@@ -188,7 +183,7 @@ PeerServer * peer_server_add(PeerServer * n, unsigned int stale_delta) {
notify_listeners(n, type);
if (!stale_timer_active) {
stale_timer_active = 1;
- post_event_with_delay(clear_stale_peers, NULL, STALE_CHECK_TIME*1000*1000);
+ post_event_with_delay(clear_stale_peers, NULL, PEER_DATA_REFRESH_PERIOD * 1000000);
}
return n;
}

Back to the top