[sr-dev] git:master: tcp: remember which connections were accepted

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Sep 21 18:50:13 CEST 2009


Module: sip-router
Branch: master
Commit: 6d263c0c6152fea5991f02a26f24a6488e94c73b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6d263c0c6152fea5991f02a26f24a6488e94c73b

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon Sep 21 18:39:41 2009 +0200

tcp: remember which connections were accepted

Use a new flag to remember which connection were passively opened
(accept()) and which were locally initiated (connect).

---

 tcp_conn.h |    1 +
 tcp_main.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tcp_conn.h b/tcp_conn.h
index 5338734..f596b59 100644
--- a/tcp_conn.h
+++ b/tcp_conn.h
@@ -75,6 +75,7 @@
 #define F_CONN_WR_ERROR  2048 /* write error on the fd */
 #define F_CONN_WANTS_RD  4096  /* conn. should be watched for READ */
 #define F_CONN_WANTS_WR  8192  /* conn. should be watched for WRITE */
+#define F_CONN_PASSIVE  16384 /* conn. created via accept() and not connect()*/
 
 
 enum tcp_req_errors {	TCP_REQ_INIT, TCP_REQ_OK, TCP_READ_ERROR,
diff --git a/tcp_main.c b/tcp_main.c
index d2f7b59..0164d22 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -3433,6 +3433,7 @@ static inline int handle_new_connect(struct socket_info* si)
 	/* add socket to list */
 	tcpconn=tcpconn_new(new_sock, &su, dst_su, si, si->proto, S_CONN_ACCEPT);
 	if (likely(tcpconn)){
+		tcpconn->flags|=F_CONN_PASSIVE;
 #ifdef TCP_PASS_NEW_CONNECTION_ON_DATA
 		atomic_set(&tcpconn->refcnt, 1); /* safe, not yet available to the
 											outside world */




More information about the sr-dev mailing list