From 875c9daca2a417bca0cdb00c9e1f1eb985528986 Mon Sep 17 00:00:00 2001 From: "Adam Roach [:abr]" Date: Tue, 4 Jun 2013 10:06:40 -0500 Subject: [PATCH] Bug 878082 - Move handle generation to after PSM setup r=jesup --- .../src/peerconnection/PeerConnectionImpl.cpp | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 8ce2c82dfa03..b20034faffcd 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -503,27 +503,6 @@ PeerConnectionImpl::Initialize(IPeerConnectionObserver* aObserver, { nsresult res; - // Generate a random handle - unsigned char handle_bin[8]; - SECStatus rv; - rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin)); - if (rv != SECSuccess) { - return NS_ERROR_UNEXPECTED; - } - - char hex[17]; - PR_snprintf(hex,sizeof(hex),"%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", - handle_bin[0], - handle_bin[1], - handle_bin[2], - handle_bin[3], - handle_bin[4], - handle_bin[5], - handle_bin[6], - handle_bin[7]); - - mHandle = hex; - // Invariant: we receive configuration one way or the other but not both (XOR) MOZ_ASSERT(!aConfiguration != !aRTCConfiguration); #ifdef MOZILLA_INTERNAL_API @@ -551,6 +530,28 @@ PeerConnectionImpl::Initialize(IPeerConnectionObserver* aObserver, NS_ENSURE_STATE(mWindow); #endif + // Generate a random handle + unsigned char handle_bin[8]; + SECStatus rv; + rv = PK11_GenerateRandom(handle_bin, sizeof(handle_bin)); + if (rv != SECSuccess) { + MOZ_CRASH(); + return NS_ERROR_UNEXPECTED; + } + + char hex[17]; + PR_snprintf(hex,sizeof(hex),"%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", + handle_bin[0], + handle_bin[1], + handle_bin[2], + handle_bin[3], + handle_bin[4], + handle_bin[5], + handle_bin[6], + handle_bin[7]); + + mHandle = hex; + res = PeerConnectionCtx::InitializeGlobal(mThread); NS_ENSURE_SUCCESS(res, res);