Hello,

Here's the patch against 5.3 server regarding ECHO_REQ vs. CHECK_ACK,
it seems to work, so far.

Still, it's a bad idea to upgrade the client while not upgrading the
server (since, as far as I see, tere's no upgrade path from upstream).
So client should be kept at last published version and a new
webclientwhatever could be packaged and clearly noted that it doesn't
have an open source server part.

ps: gosh, what an ugly code!

-- 
 byte-byte,
    grin
diff -urN dhis-server-5.3/debian/changelog dhis-server-5.3.new/debian/changelog
--- dhis-server-5.3/debian/changelog	2009-08-14 00:28:29.000000000 +0200
+++ dhis-server-5.3.new/debian/changelog	2009-08-13 23:55:04.402948447 +0200
@@ -1,3 +1,10 @@
+dhis-server (5.3-1.2.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Hack included to handle v5.5 client echos
+
+ -- Peter Gervai <g...@grin.hu>  Thu, 13 Aug 2009 23:54:37 +0200
+
 dhis-server (5.3-1.2) unstable; urgency=low
 
   * Non-maintainer upload.
diff -urN dhis-server-5.3/main.c dhis-server-5.3.new/main.c
--- dhis-server-5.3/main.c	2009-08-14 00:28:29.000000000 +0200
+++ dhis-server-5.3.new/main.c	2009-08-14 00:24:00.667948834 +0200
@@ -352,6 +352,8 @@
 
         if(msg.hdr.opcode==ECHO_REQ) {
                 echo_ack_t m;
+                online_t *p;
+		echo_req_t *mp;
 
 		DSYSLOG(1,(LOG_DEBUG,"do_dgram(): ECHO_REQ received. Sending ECHO_ACK.\n"));
 
@@ -359,7 +361,25 @@
                 m.oserial=msg.hdr.serial;
 		m.hdr.hostid=msg.hdr.hostid;
                 net_write_message((msg_t *)&m,from,msg.hdr.rport);
-                return(1);
+
+                /* hacking 5.3 server to handle 5.5 client msgs */
+		mp=(echo_req_t *)&msg;
+                p=onbase;
+		while(p!=NULL) {
+		    DSYSLOG(1,(LOG_DEBUG,"do_dgram(): ECHO_REQ hack checks online hosts; p.addr=%u p.id=%d from=%u h.id=%d\n",
+			      p->addr, p->id, from, mp->hdr.hostid));
+                 if(p->addr==from && p->id==mp->hdr.hostid) break;
+                 p=p->next;
+                } 
+                if(p==NULL) return(0);
+                /* if(mp->sid!=p->sid) return(0); */
+		DSYSLOG(1,(LOG_DEBUG,"do_dgram(): ECHO_REQ hack active to update presence (v5.5 compat). id=%d fail=%d\n",
+			  p->id, p->check_fails));
+                on_update(p->id,from,msg.hdr.rport,5,0);
+                p->ka=time(NULL) + p->refresh;
+                p->check_fails=0;
+
+		return(1);
         }
 
         if(msg.hdr.opcode==CHECK_ACK) {
diff -urN dhis-server-5.3/online.c dhis-server-5.3.new/online.c
--- dhis-server-5.3/online.c	2009-08-14 00:28:29.000000000 +0200
+++ dhis-server-5.3.new/online.c	2009-08-14 00:03:42.225947655 +0200
@@ -185,11 +185,18 @@
 
 		p2=p1->next;
 		if(p1->proto==3) 
-		if((t  - p1->ka) > KA_OFFLINE)
+		    if((t  - p1->ka) > KA_OFFLINE) {
 			on_delete(p1->id);
+			DSYSLOG(1,(LOG_DEBUG,"on_parse(): Host %d is timed out, going offline\n",
+				   p1->id));
+		    }
+
 		if(p1->proto==4 || p1->proto ==5) {
-		if(p1->check_fails > CHECK_FAILS)
+		    if(p1->check_fails > CHECK_FAILS) {
 			on_delete(p1->id);
+			DSYSLOG(1,(LOG_DEBUG,"on_parse(): Host %d failed %d checks, going offline\n",
+				   p1->id, p1->check_fails));
+		    }
 		else {
 			if (p1->proto == 4) {
 			if(p1->ka < time(NULL)) {

Reply via email to