Beispiel #1
0
void
ssl3_SetSIDSessionTicket(sslSessionID *sid,
                         /*in/out*/ NewSessionTicket *newSessionTicket)
{
    PORT_Assert(sid);
    PORT_Assert(newSessionTicket);
    PORT_Assert(newSessionTicket->ticket.data);
    PORT_Assert(newSessionTicket->ticket.len != 0);

    /* if sid->u.ssl3.lock, we are updating an existing entry that is already
     * cached or was once cached, so we need to acquire and release the write
     * lock. Otherwise, this is a new session that isn't shared with anything
     * yet, so no locking is needed.
     */
    if (sid->u.ssl3.lock) {
	PR_RWLock_Wlock(sid->u.ssl3.lock);
	if (sid->u.ssl3.locked.sessionTicket.ticket.data) {
	    SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket,
			     PR_FALSE);
	}
    }

    PORT_Assert(!sid->u.ssl3.locked.sessionTicket.ticket.data);

    /* Do a shallow copy, moving the ticket data. */
    sid->u.ssl3.locked.sessionTicket = *newSessionTicket;
    newSessionTicket->ticket.data = NULL;
    newSessionTicket->ticket.len = 0;

    if (sid->u.ssl3.lock) {
	PR_RWLock_Unlock(sid->u.ssl3.lock);
    }
}
Beispiel #2
0
void CSFLogUnregisterThread(const cprThread_t thread) {
  const cpr_thread_t *t = reinterpret_cast<cpr_thread_t *>(thread);
  thread_key_t key;
#ifdef WIN32
  key = t->threadId;
#else
  key = cprGetThreadId(thread);
#endif
  CSFLog(CSF_LOG_DEBUG, __FILE__, __LINE__, "log",
         "Unregistering thread from logging system: %s", t->name);
  PR_RWLock_Wlock(maplock);
  threadMap.erase(key);
  PR_RWLock_Unlock(maplock);
}
PKIX_Error *
PKIX_PL_AcquireWriterLock(
        PKIX_PL_RWLock *lock,
        void *plContext)
{
        PKIX_ENTER(RWLOCK, "PKIX_PL_AcquireWriterLock");
        PKIX_NULLCHECK_ONE(lock);

        PKIX_RWLOCK_DEBUG("\tCalling PR_RWLock_Wlock\n");
        (void) PR_RWLock_Wlock(lock->lock);

        if (lock->readCount > 0) {
                PKIX_ERROR(PKIX_LOCKHASNONZEROREADCOUNT);
        }

        /* We should never acquire a write lock if the lock is held */
        lock->writeLocked = PKIX_TRUE;

cleanup:

        PKIX_RETURN(RWLOCK);
}