void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
{
    unsigned long hash;
    OPENSSL_LH_NODE *nn, **rn;
    void *ret;
    lh->error = 0;
    rn = getrn(lh, data, &hash);
    if (*rn == NULL) {
        lh->num_no_delete++;
        return (NULL);
    } else {
        nn = *rn;
        *rn = nn->next;
        ret = nn->data;
        OPENSSL_free(nn);
        lh->num_delete++;
    }
    lh->num_items--;
    if ((lh->num_nodes > MIN_NODES) &&
        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))
        contract(lh);
    return (ret);
}
['int ssl_get_prev_session(SSL *s, CLIENTHELLO_MSG *hello)\n{\n    SSL_SESSION *ret = NULL;\n    int fatal = 0;\n    int try_session_cache = 1;\n    int r;\n    if (hello->session_id_len == 0)\n        try_session_cache = 0;\n    r = tls_get_ticket_from_client(s, hello, &ret);\n    switch (r) {\n    case -1:\n        fatal = 1;\n        goto err;\n    case 0:\n    case 1:\n        break;\n    case 2:\n    case 3:\n        try_session_cache = 0;\n        break;\n    default:\n        abort();\n    }\n    if (try_session_cache &&\n        ret == NULL &&\n        !(s->session_ctx->session_cache_mode &\n          SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) {\n        SSL_SESSION data;\n        data.ssl_version = s->version;\n        memset(data.session_id, 0, sizeof(data.session_id));\n        memcpy(data.session_id, hello->session_id, hello->session_id_len);\n        data.session_id_length = hello->session_id_len;\n        CRYPTO_THREAD_read_lock(s->session_ctx->lock);\n        ret = lh_SSL_SESSION_retrieve(s->session_ctx->sessions, &data);\n        if (ret != NULL) {\n            SSL_SESSION_up_ref(ret);\n        }\n        CRYPTO_THREAD_unlock(s->session_ctx->lock);\n        if (ret == NULL)\n            s->session_ctx->stats.sess_miss++;\n    }\n    if (try_session_cache &&\n        ret == NULL && s->session_ctx->get_session_cb != NULL) {\n        int copy = 1;\n        ret = s->session_ctx->get_session_cb(s, hello->session_id,\n                                             hello->session_id_len,\n                                             &copy);\n        if (ret != NULL) {\n            s->session_ctx->stats.sess_cb_hit++;\n            if (copy)\n                SSL_SESSION_up_ref(ret);\n            if (!\n                (s->session_ctx->session_cache_mode &\n                 SSL_SESS_CACHE_NO_INTERNAL_STORE)) {\n                if (SSL_CTX_add_session(s->session_ctx, ret))\n                    goto err;\n            }\n        }\n    }\n    if (ret == NULL)\n        goto err;\n    if (ret->sid_ctx_length != s->sid_ctx_length\n        || memcmp(ret->sid_ctx, s->sid_ctx, ret->sid_ctx_length)) {\n        goto err;\n    }\n    if ((s->verify_mode & SSL_VERIFY_PEER) && s->sid_ctx_length == 0) {\n        SSLerr(SSL_F_SSL_GET_PREV_SESSION,\n               SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED);\n        fatal = 1;\n        goto err;\n    }\n    if (ret->cipher == NULL) {\n        unsigned char buf[5], *p;\n        unsigned long l;\n        p = buf;\n        l = ret->cipher_id;\n        l2n(l, p);\n        if ((ret->ssl_version >> 8) >= SSL3_VERSION_MAJOR)\n            ret->cipher = ssl_get_cipher_by_char(s, &(buf[2]));\n        else\n            ret->cipher = ssl_get_cipher_by_char(s, &(buf[1]));\n        if (ret->cipher == NULL)\n            goto err;\n    }\n    if (ret->timeout < (long)(time(NULL) - ret->time)) {\n        s->session_ctx->stats.sess_timeout++;\n        if (try_session_cache) {\n            SSL_CTX_remove_session(s->session_ctx, ret);\n        }\n        goto err;\n    }\n    if (ret->flags & SSL_SESS_FLAG_EXTMS) {\n        if (!(s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS)) {\n            SSLerr(SSL_F_SSL_GET_PREV_SESSION, SSL_R_INCONSISTENT_EXTMS);\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n            fatal = 1;\n            goto err;\n        }\n    } else if (s->s3->flags & TLS1_FLAGS_RECEIVED_EXTMS) {\n        goto err;\n    }\n    s->session_ctx->stats.sess_hit++;\n    SSL_SESSION_free(s->session);\n    s->session = ret;\n    s->verify_result = s->session->verify_result;\n    return 1;\n err:\n    if (ret != NULL) {\n        SSL_SESSION_free(ret);\n        if (!try_session_cache) {\n            s->tlsext_ticket_expected = 1;\n        }\n    }\n    if (fatal)\n        return -1;\n    else\n        return 0;\n}', 'int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n{\n    return remove_session_lock(ctx, c, 1);\n}', 'static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)\n{\n    SSL_SESSION *r;\n    int ret = 0;\n    if ((c != NULL) && (c->session_id_length != 0)) {\n        if (lck)\n            CRYPTO_THREAD_write_lock(ctx->lock);\n        if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {\n            ret = 1;\n            r = lh_SSL_SESSION_delete(ctx->sessions, c);\n            SSL_SESSION_list_remove(ctx, c);\n        }\n        c->not_resumable = 1;\n        if (lck)\n            CRYPTO_THREAD_unlock(ctx->lock);\n        if (ret)\n            SSL_SESSION_free(r);\n        if (ctx->remove_session_cb != NULL)\n            ctx->remove_session_cb(ctx, c);\n    } else\n        ret = 0;\n    return (ret);\n}', 'DEFINE_LHASH_OF(SSL_SESSION)', 'void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        lh->num_no_delete++;\n        return (NULL);\n    } else {\n        nn = *rn;\n        *rn = nn->next;\n        ret = nn->data;\n        OPENSSL_free(nn);\n        lh->num_delete++;\n    }\n    lh->num_items--;\n    if ((lh->num_nodes > MIN_NODES) &&\n        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))\n        contract(lh);\n    return (ret);\n}']