Sfoglia il codice sorgente

tcp: remember which connections were accepted

Use a new flag to remember which connection were passively opened
(accept()) and which were locally initiated (connect).
Andrei Pelinescu-Onciul 16 anni fa
parent
commit
6d263c0c61
2 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 1 0
      tcp_conn.h
  2. 1 0
      tcp_main.c

+ 1 - 0
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,

+ 1 - 0
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 */