[DRBD-cvs] svn commit by phil - r2171 - branches/drbd-0.7/drbd - This patch finally fixes the connect/disconnect loop we

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Mon Apr 24 13:55:12 CEST 2006


Author: phil
Date: 2006-04-24 13:55:12 +0200 (Mon, 24 Apr 2006)
New Revision: 2171

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:
This patch finally fixes the connect/disconnect loop we had.

  In case the connection set-up of the msock takes longer
  than connect-int we came into a stable connect/disconnect
  loop. 
  Now the code recognises this and wait on one side long
  enough to break out of this loop.




Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-20 11:48:43 UTC (rev 2170)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-24 11:55:12 UTC (rev 2171)
@@ -707,6 +707,10 @@
 
 	set_cstate(mdev,WFConnection);
 
+	/* Break out of unknown connect loops by random wait here. */
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(net_random() % ((mdev->conf.try_connect_int*HZ)/4));
+
 	while(1) {
 		sock=drbd_try_connect(mdev);
 		if(sock) {
@@ -1988,10 +1992,10 @@
 	int rv;
 
 	rv = drbd_send_handshake(mdev);
-	if (!rv) return 0;
+	if (!rv) goto break_c_loop;
 
 	rv = drbd_recv_header(mdev,&p->head);
-	if (!rv) return 0;
+	if (!rv) goto break_c_loop;
 
 	if (p->head.command == ReportParams) {
 		ERR("expected HandShake packet, received ReportParams...\n");
@@ -2042,6 +2046,23 @@
 	}
 
 	return 1;
+
+ break_c_loop:
+	WARN( "My msock connect got accepted onto peer's sock!\n");
+	/* In case a tcp connection set-up takes longer than 
+	   connect-int, we might get into the situation that this
+	   node's msock gets connected to the peer's sock!
+	   
+	   To break out of this endless loop behaviour, we need to 
+	   wait unti the peer's msock connect tries are over. (1 Second)
+
+	   Additionally we wait connect-int/2 to hit with our next 
+	   connect try exactly in the peer's window of expectation. */
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(HZ + (mdev->conf.try_connect_int*HZ)/2);
+	
+	return 0;
 }
 
 int drbdd_init(struct Drbd_thread *thi)



More information about the drbd-cvs mailing list