* released 1.1.1
* fixed a bug in total failure handling
* fixed a bug in timestamp comparison within same second (tv_cmp_ms)
diff --git a/Makefile b/Makefile
index ba59843..602b057 100644
--- a/Makefile
+++ b/Makefile
@@ -46,3 +46,4 @@
 
 clean:
 	rm -vf *.[oas] *~ core haproxy test nohup.out gmon.out
+
diff --git a/doc/haproxy.txt b/doc/haproxy.txt
index 4f5ec14..f3c27af 100644
--- a/doc/haproxy.txt
+++ b/doc/haproxy.txt
@@ -1,9 +1,9 @@
 
          		     H A - P r o x y
          		     ---------------
-         		      version 1.1.0
+         		      version 1.1.1
 			      willy tarreau
-			       2002/03/10
+			       2002/03/13
 
 ==============
 |Introduction|
diff --git a/haproxy.c b/haproxy.c
index f1e183b..f0c36cd 100644
--- a/haproxy.c
+++ b/haproxy.c
@@ -9,6 +9,10 @@
  *
  * ChangeLog :
  *
+ * 2002/03/12
+ *   - released 1.1.1
+ *   - fixed a bug in total failure handling
+ *   - fixed a bug in timestamp comparison within same second (tv_cmp_ms)
  * 2002/03/10
  *   - released 1.1.0
  *   - fixed a few timeout bugs
@@ -78,8 +82,8 @@
 #include <linux/netfilter_ipv4.h>
 #endif
 
-#define HAPROXY_VERSION "1.1.0"
-#define HAPROXY_DATE	"2002/03/10"
+#define HAPROXY_VERSION "1.1.1"
+#define HAPROXY_DATE	"2002/03/13"
 
 /* this is for libc5 for example */
 #ifndef TCP_NODELAY
@@ -730,7 +734,15 @@
  * compares <tv1> and <tv2> modulo 1ms: returns 0 if equal, -1 if tv1 < tv2, 1 if tv1 > tv2
  */
 static inline int tv_cmp_ms(struct timeval *tv1, struct timeval *tv2) {
-    if ((tv1->tv_sec > tv2->tv_sec + 1) ||
+    if (tv1->tv_sec == tv2->tv_sec) {
+	if (tv1->tv_usec >= tv2->tv_usec + 1000)
+	    return 1;
+	else if (tv2->tv_usec >= tv1->tv_usec + 1000)
+	    return -1;
+	else
+	    return 0;
+    }
+    else if ((tv1->tv_sec > tv2->tv_sec + 1) ||
 	((tv1->tv_sec == tv2->tv_sec + 1) && (tv1->tv_usec + 1000000 >= tv2->tv_usec + 1000)))
 	return 1;
     else if ((tv2->tv_sec > tv1->tv_sec + 1) ||
@@ -817,7 +829,15 @@
     else if (tv_iseternity(tv2))
 	return -1; /* tv2 later than tv1 */
     
-    if ((tv1->tv_sec > tv2->tv_sec + 1) ||
+    if (tv1->tv_sec == tv2->tv_sec) {
+	if (tv1->tv_usec >= tv2->tv_usec + 1000)
+	    return 1;
+	else if (tv2->tv_usec >= tv1->tv_usec + 1000)
+	    return -1;
+	else
+	    return 0;
+    }
+    else if ((tv1->tv_sec > tv2->tv_sec + 1) ||
 	((tv1->tv_sec == tv2->tv_sec + 1) && (tv1->tv_usec + 1000000 >= tv2->tv_usec + 1000)))
 	return 1;
     else if ((tv2->tv_sec > tv1->tv_sec + 1) ||
@@ -1032,13 +1052,14 @@
     else if (s->proxy->options & PR_O_BALANCE) {
 	if (s->proxy->options & PR_O_BALANCE_RR) {
 	    int retry = s->proxy->nbservers;
-	    do {
+	    while (retry) {
 		if (s->proxy->cursrv == NULL)
 		    s->proxy->cursrv = s->proxy->srv;
 		if (s->proxy->cursrv->state & SRV_RUNNING)
 		    break;
 		s->proxy->cursrv = s->proxy->cursrv->next;
-	    } while (retry--);
+		retry--;
+	    }
 
 	    if (retry == 0) /* no server left */
 		return -1;