PJ_DEF(pj_status_t) pj_ssl_sock_close(pj_ssl_sock_t *ssock)
{
    PJ_ASSERT_RETURN(ssock, PJ_EINVAL);

    if (!ssock->pool)
	return PJ_SUCCESS;

    if (ssock->timer.id != TIMER_NONE) {
	pj_timer_heap_cancel(ssock->param.timer_heap, &ssock->timer);
	ssock->timer.id = TIMER_NONE;
    }

    ssl_reset_sock_state(ssock);

    /* Wipe out cert & key buffer. */
    if (ssock->cert) {
	pj_ssl_cert_wipe_keys(ssock->cert);
	ssock->cert = NULL;
    }

    if (ssock->param.grp_lock) {
	pj_grp_lock_dec_ref(ssock->param.grp_lock);
    } else {
	ssl_on_destroy(ssock);
    }

    return PJ_SUCCESS;
}
PJ_DEF(pj_status_t) pj_ssl_sock_close(pj_ssl_sock_t *ssock)
{
    PJ_ASSERT_RETURN(ssock, PJ_EINVAL);

    if (!ssock->pool)
	return PJ_SUCCESS;

    if (ssock->timer.id != TIMER_NONE) {
	pj_timer_heap_cancel(ssock->param.timer_heap, &ssock->timer);
	ssock->timer.id = TIMER_NONE;
    }

    ssl_reset_sock_state(ssock);

     
    if (ssock->cert) {
	pj_ssl_cert_wipe_keys(ssock->cert);
	ssock->cert = NULL;
    }

    if (ssock->param.grp_lock) {
	pj_grp_lock_dec_ref(ssock->param.grp_lock);
    } else {
	ssl_on_destroy(ssock);
    }

    return PJ_SUCCESS;
}