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);
}
['static SUB_STATE_RETURN read_state_machine(SSL *s) {\n    OSSL_STATEM *st = &s->statem;\n    int ret, mt;\n    unsigned long len = 0;\n    int (*transition)(SSL *s, int mt);\n    PACKET pkt;\n    MSG_PROCESS_RETURN (*process_message)(SSL *s, PACKET *pkt);\n    WORK_STATE (*post_process_message)(SSL *s, WORK_STATE wst);\n    unsigned long (*max_message_size)(SSL *s);\n    void (*cb) (const SSL *ssl, int type, int val) = NULL;\n    cb = get_callback(s);\n    if(s->server) {\n        transition = ossl_statem_server_read_transition;\n        process_message = ossl_statem_server_process_message;\n        max_message_size = ossl_statem_server_max_message_size;\n        post_process_message = ossl_statem_server_post_process_message;\n    } else {\n        transition = ossl_statem_client_read_transition;\n        process_message = ossl_statem_client_process_message;\n        max_message_size = ossl_statem_client_max_message_size;\n        post_process_message = ossl_statem_client_post_process_message;\n    }\n    if (st->read_state_first_init) {\n        s->first_packet = 1;\n        st->read_state_first_init = 0;\n    }\n    while(1) {\n        switch(st->read_state) {\n        case READ_STATE_HEADER:\n            if (SSL_IS_DTLS(s)) {\n                ret = dtls_get_message(s, &mt, &len);\n            } else {\n                ret = tls_get_message_header(s, &mt);\n            }\n            if (ret == 0) {\n                return SUB_STATE_ERROR;\n            }\n            if (cb != NULL) {\n                if (s->server)\n                    cb(s, SSL_CB_ACCEPT_LOOP, 1);\n                else\n                    cb(s, SSL_CB_CONNECT_LOOP, 1);\n            }\n            if(!transition(s, mt)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL3_AD_UNEXPECTED_MESSAGE);\n                SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_UNEXPECTED_MESSAGE);\n                return SUB_STATE_ERROR;\n            }\n            if (s->s3->tmp.message_size > max_message_size(s)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);\n                SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_EXCESSIVE_MESSAGE_SIZE);\n                return SUB_STATE_ERROR;\n            }\n            st->read_state = READ_STATE_BODY;\n        case READ_STATE_BODY:\n            if (!SSL_IS_DTLS(s)) {\n                ret = tls_get_message_body(s, &len);\n                if (ret == 0) {\n                    return SUB_STATE_ERROR;\n                }\n            }\n            s->first_packet = 0;\n            if (!PACKET_buf_init(&pkt, s->init_msg, len)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n                SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n                return SUB_STATE_ERROR;\n            }\n            ret = process_message(s, &pkt);\n            s->init_num = 0;\n            if (ret == MSG_PROCESS_ERROR) {\n                return SUB_STATE_ERROR;\n            }\n            if (ret == MSG_PROCESS_FINISHED_READING) {\n                if (SSL_IS_DTLS(s)) {\n                    dtls1_stop_timer(s);\n                }\n                return SUB_STATE_FINISHED;\n            }\n            if (ret == MSG_PROCESS_CONTINUE_PROCESSING) {\n                st->read_state = READ_STATE_POST_PROCESS;\n                st->read_state_work = WORK_MORE_A;\n            } else {\n                st->read_state = READ_STATE_HEADER;\n            }\n            break;\n        case READ_STATE_POST_PROCESS:\n            st->read_state_work = post_process_message(s, st->read_state_work);\n            switch(st->read_state_work) {\n            default:\n                return SUB_STATE_ERROR;\n            case WORK_FINISHED_CONTINUE:\n                st->read_state = READ_STATE_HEADER;\n                break;\n            case WORK_FINISHED_STOP:\n                if (SSL_IS_DTLS(s)) {\n                    dtls1_stop_timer(s);\n                }\n                return SUB_STATE_FINISHED;\n            }\n            break;\n        default:\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n            SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n            ossl_statem_set_error(s);\n            return SUB_STATE_ERROR;\n        }\n    }\n}', 'int tls_get_message_header(SSL *s, int *mt)\n{\n    int skip_message, i, recvd_type, al;\n    unsigned char *p;\n    unsigned long l;\n    p = (unsigned char *)s->init_buf->data;\n    do {\n        while (s->init_num < SSL3_HM_HEADER_LENGTH) {\n            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type,\n                &p[s->init_num], SSL3_HM_HEADER_LENGTH - s->init_num, 0);\n            if (i <= 0) {\n                s->rwstate = SSL_READING;\n                return 0;\n            }\n            if (recvd_type == SSL3_RT_CHANGE_CIPHER_SPEC) {\n                if (s->init_num != 0 || i != 1 || p[0] != SSL3_MT_CCS) {\n                    al = SSL_AD_UNEXPECTED_MESSAGE;\n                    SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER,\n                           SSL_R_BAD_CHANGE_CIPHER_SPEC);\n                    goto f_err;\n                }\n                s->s3->tmp.message_type = *mt = SSL3_MT_CHANGE_CIPHER_SPEC;\n                s->init_num = i - 1;\n                s->s3->tmp.message_size = i;\n                return 1;\n            } else if (recvd_type != SSL3_RT_HANDSHAKE) {\n                al = SSL_AD_UNEXPECTED_MESSAGE;\n                SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_CCS_RECEIVED_EARLY);\n                goto f_err;\n            }\n            s->init_num += i;\n        }\n        skip_message = 0;\n        if (!s->server)\n            if (p[0] == SSL3_MT_HELLO_REQUEST)\n                if (p[1] == 0 && p[2] == 0 && p[3] == 0) {\n                    s->init_num = 0;\n                    skip_message = 1;\n                    if (s->msg_callback)\n                        s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,\n                                        p, SSL3_HM_HEADER_LENGTH, s,\n                                        s->msg_callback_arg);\n                }\n    } while (skip_message);\n    *mt = *p;\n    s->s3->tmp.message_type = *(p++);\n    if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) {\n        l = RECORD_LAYER_get_rrec_length(&s->rlayer)\n            + SSL3_HM_HEADER_LENGTH;\n        if (l && !BUF_MEM_grow_clean(s->init_buf, (int)l)) {\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB);\n            goto err;\n        }\n        s->s3->tmp.message_size = l;\n        s->init_msg = s->init_buf->data;\n        s->init_num = SSL3_HM_HEADER_LENGTH;\n    } else {\n        n2l3(p, l);\n        if (l > (INT_MAX - SSL3_HM_HEADER_LENGTH)) {\n            al = SSL_AD_ILLEGAL_PARAMETER;\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_EXCESSIVE_MESSAGE_SIZE);\n            goto f_err;\n        }\n        if (l && !BUF_MEM_grow_clean(s->init_buf,\n                                    (int)l + SSL3_HM_HEADER_LENGTH)) {\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB);\n            goto err;\n        }\n        s->s3->tmp.message_size = l;\n        s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH;\n        s->init_num = 0;\n    }\n    return 1;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    return 0;\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    desc = s->method->ssl3_enc->alert_value(desc);\n    if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)\n        desc = SSL_AD_HANDSHAKE_FAILURE;\n    if (desc < 0)\n        return -1;\n    if ((level == SSL3_AL_FATAL) && (s->session != NULL))\n        SSL_CTX_remove_session(s->session_ctx, s->session);\n    s->s3->alert_dispatch = 1;\n    s->s3->send_alert[0] = level;\n    s->s3->send_alert[1] = desc;\n    if (!RECORD_LAYER_write_pending(&s->rlayer)) {\n        return s->method->ssl_dispatch_alert(s);\n    }\n    return -1;\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        if (lck)\n            CRYPTO_THREAD_unlock(ctx->lock);\n        if (ret) {\n            r->not_resumable = 1;\n            if (ctx->remove_session_cb != NULL)\n                ctx->remove_session_cb(ctx, r);\n            SSL_SESSION_free(r);\n        }\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}']