Start RAIIification for TLS.
This commit is contained in:
@@ -64,28 +64,28 @@
|
|||||||
#define CERT_STATUS_BAD 3
|
#define CERT_STATUS_BAD 3
|
||||||
#define CERT_STATUS_USER_ACCEPTED 4
|
#define CERT_STATUS_USER_ACCEPTED 4
|
||||||
|
|
||||||
typedef struct {
|
struct Server_t {
|
||||||
char *hostname;
|
char *hostname;
|
||||||
int port;
|
int port;
|
||||||
int cert_status;
|
int cert_status;
|
||||||
} Server_t;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct FdMapEntry_t {
|
||||||
int fd;
|
int fd;
|
||||||
int connkey;
|
int connkey;
|
||||||
} FdMapEntry_t;
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data type for TLS connection information
|
* Data type for TLS connection information
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
struct Conn_t {
|
||||||
int fd;
|
int fd;
|
||||||
DilloUrl *url;
|
DilloUrl *url;
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
bool connecting;
|
bool connecting;
|
||||||
bool in_connect;
|
bool in_connect;
|
||||||
bool do_shutdown;
|
bool do_shutdown;
|
||||||
} Conn_t;
|
};
|
||||||
|
|
||||||
/* List of active TLS connections */
|
/* List of active TLS connections */
|
||||||
static Klist_t *conn_list = NULL;
|
static Klist_t *conn_list = NULL;
|
||||||
@@ -166,7 +166,7 @@ static int Tls_conn_new(int fd, const DilloUrl *url, SSL *ssl)
|
|||||||
{
|
{
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
Conn_t *conn = dNew0(Conn_t, 1);
|
Conn_t *conn = std::make_unique< Conn_t >().release();
|
||||||
conn->fd = fd;
|
conn->fd = fd;
|
||||||
conn->url = a_Url_dup(url).release();
|
conn->url = a_Url_dup(url).release();
|
||||||
conn->ssl = ssl;
|
conn->ssl = ssl;
|
||||||
@@ -415,7 +415,7 @@ int a_Tls_openssl_connect_ready(const DilloUrl *url)
|
|||||||
if (s->cert_status == CERT_STATUS_NONE)
|
if (s->cert_status == CERT_STATUS_NONE)
|
||||||
s->cert_status = CERT_STATUS_RECEIVING;
|
s->cert_status = CERT_STATUS_RECEIVING;
|
||||||
} else {
|
} else {
|
||||||
s = dNew(Server_t, 1);
|
s = std::make_unique< Server_t >().release();
|
||||||
|
|
||||||
s->hostname = dStrdup(URL_HOST(url));
|
s->hostname = dStrdup(URL_HOST(url));
|
||||||
s->port = URL_PORT(url);
|
s->port = URL_PORT(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user