瀏覽代碼

tcp: tls fix_read_con hook return changes

tls_fix_read_con doesn't change the tcp connection state any
longer, relying instead on different return codes.
Andrei Pelinescu-Onciul 16 年之前
父節點
當前提交
c390fed30a
共有 2 個文件被更改,包括 8 次插入4 次删除
  1. 3 3
      tcp_read.c
  2. 5 1
      tls_hooks.h

+ 3 - 3
tcp_read.c

@@ -651,11 +651,11 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
 		req=&con->req;
 #ifdef USE_TLS
 		if (con->type==PROTO_TLS){
-			if (tls_fix_read_conn(con)!=0){
+			ret=tls_fix_read_conn(con);
+			if (unlikely(ret<0)){
 				resp=CONN_ERROR;
 				goto end_req;
-			}
-			if (unlikely(con->state!=S_CONN_OK && con->state!=S_CONN_ACCEPT))
+			}else if (unlikely(ret==0))
 				goto end_req; /* not enough data */
 		}
 #endif

+ 5 - 1
tls_hooks.h

@@ -51,7 +51,11 @@ struct tls_hooks{
 	/* checks if a tls connection is fully established before a read, and if 
 	 * not it runs tls_accept() or tls_connect() as needed
 	 * (tls_accept and tls_connect are deferred to the "reader" process for
-	 *  performance reasons) */
+	 *  performance reasons)
+	 * returns 1 if the read can continue, 0 if the connection is not yet
+	 * ready for the read and fix_read_con() should be attempted at a latter
+	 * time and <0 on error.
+	 */
 	int (*fix_read_con)(struct tcp_connection* c);
 	
 	/* per listening socket init, called on ser startup (after modules,