9d7d3f
From 8d25353ae1661ce50fe564e733f3ef45004f4bdf Mon Sep 17 00:00:00 2001
9d7d3f
From: Kamil Dudka <kdudka@redhat.com>
9d7d3f
Date: Tue, 5 Mar 2013 17:51:01 +0100
9d7d3f
Subject: [PATCH] nss: fix misplaced code enabling non-blocking socket mode
9d7d3f
9d7d3f
The option needs to be set on the SSL socket.  Setting it on the model
9d7d3f
takes no effect.  Note that the non-blocking mode is still not enabled
9d7d3f
for the handshake because the code is not yet ready for that.
9d7d3f
9d7d3f
[upstream commit 9d0af3018c5db25f5adda216dbcad6056b4a3107]
9d7d3f
---
9d7d3f
 lib/nss.c |   12 ++++++------
9d7d3f
 1 files changed, 6 insertions(+), 6 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/nss.c b/lib/nss.c
9d7d3f
index 8a2cb09..a2c5c63 100644
9d7d3f
--- a/lib/nss.c
9d7d3f
+++ b/lib/nss.c
9d7d3f
@@ -1237,12 +1237,6 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
9d7d3f
     goto error;
9d7d3f
   model = SSL_ImportFD(NULL, model);
9d7d3f
 
9d7d3f
-  /* make the socket nonblocking */
9d7d3f
-  sock_opt.option = PR_SockOpt_Nonblocking;
9d7d3f
-  sock_opt.value.non_blocking = PR_TRUE;
9d7d3f
-  if(PR_SetSocketOption(model, &sock_opt) != PR_SUCCESS)
9d7d3f
-    goto error;
9d7d3f
-
9d7d3f
   if(SSL_OptionSet(model, SSL_SECURITY, PR_TRUE) != SECSuccess)
9d7d3f
     goto error;
9d7d3f
   if(SSL_OptionSet(model, SSL_HANDSHAKE_AS_SERVER, PR_FALSE) != SECSuccess)
9d7d3f
@@ -1415,6 +1409,12 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
9d7d3f
     goto error;
9d7d3f
   }
9d7d3f
 
9d7d3f
+  /* switch the SSL socket into non-blocking mode */
9d7d3f
+  sock_opt.option = PR_SockOpt_Nonblocking;
9d7d3f
+  sock_opt.value.non_blocking = PR_TRUE;
9d7d3f
+  if(PR_SetSocketOption(connssl->handle, &sock_opt) != PR_SUCCESS)
9d7d3f
+    goto error;
9d7d3f
+
9d7d3f
   connssl->state = ssl_connection_complete;
9d7d3f
   conn->recv[sockindex] = nss_recv;
9d7d3f
   conn->send[sockindex] = nss_send;
9d7d3f
-- 
9d7d3f
1.7.1
9d7d3f