/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <poll.h>
#include "adr_stream.h"
/*
* Common adr_stream implementation
*/
struct adr_stream {
void *astr_data;
void (*astr_close)(void *);
void (*astr_free)(void *);
};
{
return (NULL);
}
return (result);
}
{
}
{
}
void
{
}
void
{
}
/*
* File descriptor stream implementation.
*/
typedef struct adr_fdstream {
int infd;
int outfd;
static ssize_t
{
}
static ssize_t
{
}
static void
{
int fd;
}
}
static void
{
}
{
return (NULL);
}
return (NULL);
return (result);
}
{
}
static unsigned long
adr_ssl_id_function(void)
{
return (pthread_self());
}
/* ARGSUSED */
static void
{
if (mode & CRYPTO_LOCK)
(void) pthread_mutex_lock(&crypto_locks[n]);
else
(void) pthread_mutex_unlock(&crypto_locks[n]);
}
void
adr_ssl_init(void)
{
if (crypto_locks == NULL)
abort();
for (int i = 0; i < CRYPTO_num_locks(); i++)
}
/*
* SSL stream implementation
*
* Neither documentation nor internet chatter is clear on whether it is
* legal to call SSL_write after an SSL_read that returns
* SSL_ERROR_WANT_* before completing the SSL_read (and vice versa),
* but I don't see how the interfaces are otherwise usable without
* introducing cross-connection deadlocks.
*
* To avoid the single-side deadlock situation where one thread reads
* socket data between when the other drops its lock and starts to poll
* for it, we call poll with a 5 second timeout. This limits the time
* spent polling (in the traditional sense) the socket, and lets us to
* check every once in a while in case this rare situation arises, all
* without the per-connection overhead more precise solutions require.
*/
typedef struct adr_sslstream {
int fd;
static void
{
int fd;
}
}
}
static boolean_t
{
if (res == -1) {
if (err == SSL_ERROR_WANT_READ)
else if (err == SSL_ERROR_WANT_WRITE)
else
goto out;
/*
* Poll for the ability to do so, and retry.
*
* Use a timeout in case a renegotiation caused another
* Much simpler than implementing a precise wakeup.
*/
return (B_TRUE);
}
out:
return (B_FALSE);
}
static ssize_t
{
int res;
do {
/*
* We're done.
*/
return (0);
}
if (res > 0) {
return (res);
}
/* drops lock */
return (res);
}
static ssize_t
{
int res;
do {
/*
* We're done.
*/
return (0);
}
if (res > 0) {
return (res);
}
/* drops lock */
return (res);
}
static void
{
}
static void
{
}
{
return (NULL);
}
return (NULL);
return (result);
}