sslproc: simplify ssl open callback
Don't use the librb callback type as we're always passing client_p. Provide a return value so that the connect handler can exit_client() and the accept handler can opt to use the default dead handler.
This commit is contained in:
parent
e1f16ce22e
commit
53789fddda
3 changed files with 20 additions and 15 deletions
|
@ -68,6 +68,8 @@ struct ListClient;
|
||||||
struct scache_entry;
|
struct scache_entry;
|
||||||
struct ws_ctl;
|
struct ws_ctl;
|
||||||
|
|
||||||
|
typedef int SSL_OPEN_CB(struct Client *, int status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Client structures
|
* Client structures
|
||||||
*/
|
*/
|
||||||
|
@ -275,8 +277,7 @@ struct LocalUser
|
||||||
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
|
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
|
||||||
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
|
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
|
||||||
struct ws_ctl *ws_ctl; /* ctl for wsockd */
|
struct ws_ctl *ws_ctl; /* ctl for wsockd */
|
||||||
CNCB *ssl_callback; /* ssl connection is now open */
|
SSL_OPEN_CB *ssl_callback; /* ssl connection is now open */
|
||||||
void *ssl_data; /* data for callback */
|
|
||||||
uint32_t localflags;
|
uint32_t localflags;
|
||||||
struct ZipStats *zipstats; /* zipstats */
|
struct ZipStats *zipstats; /* zipstats */
|
||||||
uint16_t cork_count; /* used for corking/uncorking connections */
|
uint16_t cork_count; /* used for corking/uncorking connections */
|
||||||
|
|
|
@ -151,6 +151,7 @@ init_builtin_capabs(void)
|
||||||
|
|
||||||
static CNCB serv_connect_callback;
|
static CNCB serv_connect_callback;
|
||||||
static CNCB serv_connect_ssl_callback;
|
static CNCB serv_connect_ssl_callback;
|
||||||
|
static SSL_OPEN_CB serv_connect_ssl_open_callback;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* hunt_server - Do the basic thing in delivering the message (command)
|
* hunt_server - Do the basic thing in delivering the message (command)
|
||||||
|
@ -1180,8 +1181,7 @@ serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
|
||||||
|
|
||||||
}
|
}
|
||||||
client_p->localClient->F = xF[0];
|
client_p->localClient->F = xF[0];
|
||||||
client_p->localClient->ssl_callback = serv_connect_callback;
|
client_p->localClient->ssl_callback = serv_connect_ssl_open_callback;
|
||||||
client_p->localClient->ssl_data = data;
|
|
||||||
|
|
||||||
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], connid_get(client_p));
|
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], connid_get(client_p));
|
||||||
if(!client_p->localClient->ssl_ctl)
|
if(!client_p->localClient->ssl_ctl)
|
||||||
|
@ -1192,6 +1192,13 @@ serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
|
||||||
SetSSL(client_p);
|
SetSSL(client_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
serv_connect_ssl_open_callback(struct Client *client_p, int status)
|
||||||
|
{
|
||||||
|
serv_connect_callback(client_p->localClient->F, status, client_p);
|
||||||
|
return 1; /* suppress default exit_client handler for status != RB_OK */
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* serv_connect_callback() - complete a server connection.
|
* serv_connect_callback() - complete a server connection.
|
||||||
*
|
*
|
||||||
|
|
|
@ -393,13 +393,11 @@ ssl_process_open_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
||||||
|
|
||||||
if(client_p->localClient->ssl_callback)
|
if(client_p->localClient->ssl_callback)
|
||||||
{
|
{
|
||||||
CNCB *hdl = client_p->localClient->ssl_callback;
|
SSL_OPEN_CB *hdl = client_p->localClient->ssl_callback;
|
||||||
void *data = client_p->localClient->ssl_data;
|
|
||||||
|
|
||||||
client_p->localClient->ssl_callback = NULL;
|
client_p->localClient->ssl_callback = NULL;
|
||||||
client_p->localClient->ssl_data = NULL;
|
|
||||||
|
|
||||||
hdl(client_p->localClient->F, RB_OK, data);
|
hdl(client_p, RB_OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,16 +426,15 @@ ssl_process_dead_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
|
||||||
/* if there is still a pending callback, call it now */
|
/* if there is still a pending callback, call it now */
|
||||||
if(client_p->localClient->ssl_callback)
|
if(client_p->localClient->ssl_callback)
|
||||||
{
|
{
|
||||||
CNCB *hdl = client_p->localClient->ssl_callback;
|
SSL_OPEN_CB *hdl = client_p->localClient->ssl_callback;
|
||||||
void *data = client_p->localClient->ssl_data;
|
|
||||||
|
|
||||||
client_p->localClient->ssl_callback = NULL;
|
client_p->localClient->ssl_callback = NULL;
|
||||||
client_p->localClient->ssl_data = NULL;
|
|
||||||
|
|
||||||
hdl(client_p->localClient->F, RB_ERROR_SSL, data);
|
if (hdl(client_p, RB_ERROR_SSL))
|
||||||
|
{
|
||||||
/* the callback should have exited the client */
|
/* the callback has exited the client */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(IsAnyServer(client_p) || IsRegistered(client_p))
|
if(IsAnyServer(client_p) || IsRegistered(client_p))
|
||||||
|
|
Loading…
Reference in a new issue