Browse code

- local_timer cleanup (always use local_timer*, don't mix them with timer_*) - tcp fix: clear the write watch flag after empting the write buffers

Andrei Pelinescu-Onciul authored on 11/12/2007 20:11:01
Showing 3 changed files
... ...
@@ -48,6 +48,10 @@ struct local_timer {
48 48
 };
49 49
 
50 50
 
51
+#define local_timer_init(tl, fun, param, flgs) timer_init(tl, fun, param, flgs)
52
+
53
+#define local_timer_reinit(tl) timer_reinit((tl))
54
+
51 55
 int init_local_timer(struct local_timer *lt_handle, ticks_t crt_ticks);
52 56
 void destroy_local_timer(struct local_timer* lt_handle);
53 57
 
... ...
@@ -813,7 +813,7 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
813 813
 	c->rcv.src_su=*su;
814 814
 	
815 815
 	atomic_set(&c->refcnt, 0);
816
-	timer_init(&c->timer, tcpconn_main_timeout, c, 0);
816
+	local_timer_init(&c->timer, tcpconn_main_timeout, c, 0);
817 817
 	su2ip_addr(&c->rcv.src_ip, su);
818 818
 	c->rcv.src_port=su_getport(su);
819 819
 	c->rcv.bind_address=ba;
... ...
@@ -1786,7 +1786,7 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
1786 1786
 			/* re-activate the timer only if the connection is handled
1787 1787
 			 * by tcp_main (and not by a tcp reader)*/
1788 1788
 			tcpconn->timer.f=tcpconn_main_timeout;
1789
-			timer_reinit(&tcpconn->timer);
1789
+			local_timer_reinit(&tcpconn->timer);
1790 1790
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
1791 1791
 									TCPCONN_WAIT_TIMEOUT, t);
1792 1792
 		}
... ...
@@ -2061,7 +2061,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
2061 2061
 			tcpconn_put(tcpconn);
2062 2062
 			/* re-activate the timer */
2063 2063
 			tcpconn->timer.f=tcpconn_main_timeout;
2064
-			timer_reinit(&tcpconn->timer);
2064
+			local_timer_reinit(&tcpconn->timer);
2065 2065
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
2066 2066
 								tcp_con_lifetime, t);
2067 2067
 			/* must be after the de-ref*/
... ...
@@ -2522,6 +2522,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
2522 2522
 											POLLIN, fd_i)==-1))
2523 2523
 					goto error;
2524 2524
 			}
2525
+			tcpconn->flags&=~F_CONN_WRITE_W;
2525 2526
 		}
2526 2527
 		ev&=~POLLOUT; /* clear POLLOUT */
2527 2528
 	}
... ...
@@ -779,7 +779,7 @@ again:
779 779
 			con->timeout=t+S_TO_TICKS(TCP_CHILD_TIMEOUT);
780 780
 			/* re-activate the timer */
781 781
 			con->timer.f=tcpconn_read_timeout;
782
-			timer_reinit(&con->timer);
782
+			local_timer_reinit(&con->timer);
783 783
 			local_timer_add(&tcp_reader_ltimer, &con->timer,
784 784
 								S_TO_TICKS(TCP_CHILD_TIMEOUT), t);
785 785
 			if (unlikely(io_watch_add(&io_w, s, POLLIN, F_TCPCONN, con))<0){