ソースを参照

- tls shutdown on close support
- some tcp bug fixes (error handling in case of bad
fds, or impossible events [like conn==0])

Andrei Pelinescu-Onciul 22 年 前
コミット
f535fd9aad
3 ファイル変更19 行追加10 行削除
  1. 1 1
      Makefile.defs
  2. 9 0
      tcp_main.c
  3. 9 9
      tcp_read.c

+ 1 - 1
Makefile.defs

@@ -40,7 +40,7 @@ export makefile_defs
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL =   12
-EXTRAVERSION = dev-t08
+EXTRAVERSION = dev-t09
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 9 - 0
tcp_main.c

@@ -41,6 +41,7 @@
  *  2003-04-14  set sockopts to TOS low delay (andrei)
  *  2003-06-30  moved tcp new connect checking & handling to
  *               handle_new_connect (andrei)
+ *  2003-07-09  tls_close called before closing the tcp connection (andrei)
  */
 
 
@@ -520,6 +521,10 @@ void tcpconn_timeout(fd_set* set)
 				DBG("tcpconn_timeout: timeout for hash=%d - %p (%d > %d)\n",
 						h, c, ticks, c->timeout);
 				fd=c->s;
+#ifdef USE_TLS
+				if (c->type==PROTO_TLS)
+					tls_close(c, fd);
+#endif
 				_tcpconn_rm(c);
 				if (fd>0) {
 					FD_CLR(fd, set);
@@ -861,6 +866,10 @@ read_again:
 							if (tcpconn->refcnt==0){ 
 								DBG("tcp_main_loop: destroying connection\n");
 								fd=tcpconn->s;
+#ifdef USE_TLS
+								if (tcpconn->type==PROTO_TLS)
+									tls_close(tcpconn, fd);
+#endif
 								_tcpconn_rm(tcpconn);
 								close(fd);
 							}else{

+ 9 - 9
tcp_read.c

@@ -600,31 +600,30 @@ void tcp_receive_loop(int unix_sock)
 				if (n<0){
 					if (errno == EWOULDBLOCK || errno == EAGAIN ||
 							errno == EINTR){
-						continue;
+						goto skip;
 					}else{
 						LOG(L_CRIT,"BUG: tcp_receive_loop: read_fd: %s\n",
 							strerror(errno));
 						abort(); /* big error*/
 					}
 				}
+				DBG("received n=%d con=%p, fd=%d\n", n, con, s);
 				if (n==0){
 					LOG(L_ERR, "WARNING: tcp_receive_loop: 0 bytes read\n");
-					continue;
+					goto skip;
+				}
+				if (con==0){
+					LOG(L_CRIT, "BUG: tcp_receive_loop: null pointer\n");
+					goto skip;
 				}
 				con->fd=s;
-				DBG("received n=%d con=%p, fd=%d\n", n, con, s);
 				if (s==-1) {
 					LOG(L_ERR, "ERROR: tcp_receive_loop: read_fd:"
 									"no fd read\n");
 					resp=CONN_ERROR;
 					con->state=S_CONN_BAD;
 					release_tcpconn(con, resp, unix_sock);
-				}
-				if (con==0){
-					LOG(L_ERR, "ERROR: tcp_receive_loop: null pointer\n");
-					resp=CONN_ERROR;
-					con->state=S_CONN_BAD;
-					release_tcpconn(con, resp, unix_sock);
+					goto skip;
 				}
 #ifdef USE_TLS
 				if (con->type==PROTO_TLS) tls_tcpconn_update_fd(con, s);
@@ -634,6 +633,7 @@ void tcp_receive_loop(int unix_sock)
 				if (maxfd<s) maxfd=s;
 				tcpconn_listadd(list, con, c_next, c_prev);
 			}
+skip:
 			ticks=get_ticks();
 			for (con=list; con ; con=c_next){
 				c_next=con->c_next; /* safe for removing*/