Browse Source

- 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 18 years ago
parent
commit
8b0472d783
3 changed files with 9 additions and 4 deletions
  1. 4 0
      local_timer.h
  2. 4 3
      tcp_main.c
  3. 1 1
      tcp_read.c

+ 4 - 0
local_timer.h

@@ -48,6 +48,10 @@ struct local_timer {
 };
 
 
+#define local_timer_init(tl, fun, param, flgs) timer_init(tl, fun, param, flgs)
+
+#define local_timer_reinit(tl) timer_reinit((tl))
+
 int init_local_timer(struct local_timer *lt_handle, ticks_t crt_ticks);
 void destroy_local_timer(struct local_timer* lt_handle);
 

+ 4 - 3
tcp_main.c

@@ -813,7 +813,7 @@ struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su,
 	c->rcv.src_su=*su;
 	
 	atomic_set(&c->refcnt, 0);
-	timer_init(&c->timer, tcpconn_main_timeout, c, 0);
+	local_timer_init(&c->timer, tcpconn_main_timeout, c, 0);
 	su2ip_addr(&c->rcv.src_ip, su);
 	c->rcv.src_port=su_getport(su);
 	c->rcv.bind_address=ba;
@@ -1786,7 +1786,7 @@ static void tcpconn_destroy(struct tcp_connection* tcpconn)
 			/* re-activate the timer only if the connection is handled
 			 * by tcp_main (and not by a tcp reader)*/
 			tcpconn->timer.f=tcpconn_main_timeout;
-			timer_reinit(&tcpconn->timer);
+			local_timer_reinit(&tcpconn->timer);
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
 									TCPCONN_WAIT_TIMEOUT, t);
 		}
@@ -2061,7 +2061,7 @@ inline static int handle_tcp_child(struct tcp_child* tcp_c, int fd_i)
 			tcpconn_put(tcpconn);
 			/* re-activate the timer */
 			tcpconn->timer.f=tcpconn_main_timeout;
-			timer_reinit(&tcpconn->timer);
+			local_timer_reinit(&tcpconn->timer);
 			local_timer_add(&tcp_main_ltimer, &tcpconn->timer, 
 								tcp_con_lifetime, t);
 			/* must be after the de-ref*/
@@ -2522,6 +2522,7 @@ inline static int handle_tcpconn_ev(struct tcp_connection* tcpconn, short ev,
 											POLLIN, fd_i)==-1))
 					goto error;
 			}
+			tcpconn->flags&=~F_CONN_WRITE_W;
 		}
 		ev&=~POLLOUT; /* clear POLLOUT */
 	}

+ 1 - 1
tcp_read.c

@@ -779,7 +779,7 @@ again:
 			con->timeout=t+S_TO_TICKS(TCP_CHILD_TIMEOUT);
 			/* re-activate the timer */
 			con->timer.f=tcpconn_read_timeout;
-			timer_reinit(&con->timer);
+			local_timer_reinit(&con->timer);
 			local_timer_add(&tcp_reader_ltimer, &con->timer,
 								S_TO_TICKS(TCP_CHILD_TIMEOUT), t);
 			if (unlikely(io_watch_add(&io_w, s, POLLIN, F_TCPCONN, con))<0){