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