ssl_NewSocket(void)
ssl_NewSocket(PRBool makeLocks)
ssl_NewSocket(void){    sslSocket *ss;#ifdef DEBUG#if (defined(XP_UNIX) || defined(XP_WIN32) || defined(XP_BEOS)) && !defined(_WIN32_WCE)    static int firsttime = 1;    if (firsttime) {	firsttime = 0;	{	    char *ev = getenv("SSLDEBUG");	    if (ev && ev[0]) {		ssl_debug = atoi(ev);		SSL_TRACE(("SSL: debugging set to %d", ssl_debug));	    }	}#ifdef TRACE	{	    char *ev = getenv("SSLTRACE");	    if (ev && ev[0]) {		ssl_trace = atoi(ev);		SSL_TRACE(("SSL: tracing set to %d", ssl_trace));	    }	}#endif /* TRACE */    }#endif /* XP_UNIX || XP_WIN32 */#endif /* DEBUG */    /* Make a new socket and get it ready */    ss = (sslSocket*) PORT_ZAlloc(sizeof(sslSocket));    if (ss) {        /* This should be of type SSLKEAType, but CC on IRIX	 * complains during the for loop.	 */	int i;	SECStatus status; 	ss->useSecurity        = ssl_defaults.useSecurity;	ss->useSocks           = PR_FALSE;	ss->requestCertificate = ssl_defaults.requestCertificate;	ss->requireCertificate = ssl_defaults.requireCertificate;	ss->handshakeAsClient  = ssl_defaults.handshakeAsClient;	ss->handshakeAsServer  = ssl_defaults.handshakeAsServer;	ss->enableSSL2         = ssl_defaults.enableSSL2;	ss->enableSSL3         = ssl_defaults.enableSSL3;	ss->enableTLS          = ssl_defaults.enableTLS ;	ss->fdx                = ssl_defaults.fdx;	ss->v2CompatibleHello  = ssl_defaults.v2CompatibleHello;	ss->detectRollBack     = ssl_defaults.detectRollBack;	ss->noStepDown         = ssl_defaults.noStepDown;	ss->noCache            = ssl_defaults.noCache;	ss->peerID             = NULL;	ss->rTimeout	       = PR_INTERVAL_NO_TIMEOUT;	ss->wTimeout	       = PR_INTERVAL_NO_TIMEOUT;	ss->cTimeout	       = PR_INTERVAL_NO_TIMEOUT;	ss->cipherSpecs        = NULL;        ss->sizeCipherSpecs    = 0;  /* produced lazily */        ss->preferredCipher    = NULL;        ss->url                = NULL;	for (i=kt_null; i < kt_kea_size; i++) {	    sslServerCerts * sc = ss->serverCerts + i;	    sc->serverCert      = NULL;	    sc->serverCertChain = NULL;	    sc->serverKey       = NULL;	    sc->serverKeyBits   = 0;	}	ss->stepDownKeyPair    = NULL;	ss->dbHandle           = CERT_GetDefaultCertDB();	/* Provide default implementation of hooks */	ss->authCertificate    = SSL_AuthCertificate;	ss->authCertificateArg = (void *)ss->dbHandle;	ss->getClientAuthData  = NULL;	ss->handleBadCert      = NULL;	ss->badCertArg         = NULL;	ss->pkcs11PinArg       = NULL;	ssl_ChooseOps(ss);	ssl2_InitSocketPolicy(ss);	ssl3_InitSocketPolicy(ss);	ss->firstHandshakeLock = PZ_NewMonitor(nssILockSSL);	if (!ss->firstHandshakeLock) goto loser;	ss->ssl3HandshakeLock  = PZ_NewMonitor(nssILockSSL);	if (!ss->ssl3HandshakeLock) goto loser;	ss->specLock           = NSSRWLock_New(SSL_LOCK_RANK_SPEC, NULL);	if (!ss->specLock) goto loser;	ss->recvBufLock        = PZ_NewMonitor(nssILockSSL);	if (!ss->recvBufLock) goto loser;	ss->xmitBufLock        = PZ_NewMonitor(nssILockSSL);	if (!ss->xmitBufLock) goto loser;	ss->writerThread       = NULL;	if (ssl_lock_readers) {	    ss->recvLock       = PZ_NewLock(nssILockSSL);	    if (!ss->recvLock) goto loser;	    ss->sendLock       = PZ_NewLock(nssILockSSL);	    if (!ss->sendLock) goto loser;	}	status = ssl_CreateSecurityInfo(ss);	if (status != SECSuccess) goto loser;	status = ssl_InitGather(&ss->gs);	if (status != SECSuccess) {loser:	    ssl_DestroySocketContents(ss);	    ssl_DestroyLocks(ss);	    PORT_Free(ss);	    ss = NULL;	}    }    return ss;}