Browse code

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 authored on 21/09/2009 16:41:26
Showing 2 changed files
... ...
@@ -651,11 +651,11 @@ int tcp_read_req(struct tcp_connection* con, int* bytes_read, int* read_flags)
651 651
 		req=&con->req;
652 652
 #ifdef USE_TLS
653 653
 		if (con->type==PROTO_TLS){
654
-			if (tls_fix_read_conn(con)!=0){
654
+			ret=tls_fix_read_conn(con);
655
+			if (unlikely(ret<0)){
655 656
 				resp=CONN_ERROR;
656 657
 				goto end_req;
657
-			}
658
-			if (unlikely(con->state!=S_CONN_OK && con->state!=S_CONN_ACCEPT))
658
+			}else if (unlikely(ret==0))
659 659
 				goto end_req; /* not enough data */
660 660
 		}
661 661
 #endif
... ...
@@ -51,7 +51,11 @@ struct tls_hooks{
51 51
 	/* checks if a tls connection is fully established before a read, and if 
52 52
 	 * not it runs tls_accept() or tls_connect() as needed
53 53
 	 * (tls_accept and tls_connect are deferred to the "reader" process for
54
-	 *  performance reasons) */
54
+	 *  performance reasons)
55
+	 * returns 1 if the read can continue, 0 if the connection is not yet
56
+	 * ready for the read and fix_read_con() should be attempted at a latter
57
+	 * time and <0 on error.
58
+	 */
55 59
 	int (*fix_read_con)(struct tcp_connection* c);
56 60
 	
57 61
 	/* per listening socket init, called on ser startup (after modules,