mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-06-30 22:18:19 -04:00
Update: Added more logging and call SSL_shutdown() more conditionally
This commit is contained in:
parent
25a4645245
commit
889f2bfa94
@ -1099,23 +1099,30 @@ static int _need_body(client_queue_entry_t *node)
|
|||||||
{
|
{
|
||||||
client_t *client = node->client;
|
client_t *client = node->client;
|
||||||
|
|
||||||
if (node->tried_body)
|
if (node->tried_body) {
|
||||||
|
ICECAST_LOG_DEBUG("tried_body is true (client=%p)", client);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (client->parser->req_type == httpp_req_source) {
|
if (client->parser->req_type == httpp_req_source) {
|
||||||
/* SOURCE connection. */
|
/* SOURCE connection. */
|
||||||
|
ICECAST_LOG_DEBUG("SOURCE connection (client=%p)", client);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (client->parser->req_type == httpp_req_put) {
|
} else if (client->parser->req_type == httpp_req_put) {
|
||||||
/* PUT connection.
|
/* PUT connection.
|
||||||
* TODO: We may need body for /admin/ but we do not know if it's an admin request yet.
|
* TODO: We may need body for /admin/ but we do not know if it's an admin request yet.
|
||||||
*/
|
*/
|
||||||
|
ICECAST_LOG_DEBUG("PUT connection (client=%p)", client);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (client->request_body_length != -1 && (size_t)client->request_body_length != client->request_body_read) {
|
} else if (client->request_body_length != -1 && (size_t)client->request_body_length != client->request_body_read) {
|
||||||
|
ICECAST_LOG_DEBUG("request_body_length missmatch (client=%p)", client);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (client->request_body_length == -1 && client_body_eof(client) == 0) {
|
} else if (client->request_body_length == -1 && client_body_eof(client) == 0) {
|
||||||
|
ICECAST_LOG_DEBUG("Unknown body length (client=%p)", client);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ICECAST_LOG_DEBUG("No body (client=%p)", client);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/tls.c
20
src/tls.c
@ -53,6 +53,7 @@ struct tls_tag {
|
|||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
tls_ctx_t *ctx;
|
tls_ctx_t *ctx;
|
||||||
bool error;
|
bool error;
|
||||||
|
bool no_shutdown;
|
||||||
};
|
};
|
||||||
|
|
||||||
void tls_initialize(void)
|
void tls_initialize(void)
|
||||||
@ -164,6 +165,8 @@ tls_t *tls_new(tls_ctx_t *ctx)
|
|||||||
tls->ssl = ssl;
|
tls->ssl = ssl;
|
||||||
tls->ctx = ctx;
|
tls->ctx = ctx;
|
||||||
|
|
||||||
|
ICECAST_LOG_DEBUG("tls_new(ctx=%p) = %p", ctx, tls);
|
||||||
|
|
||||||
return tls;
|
return tls;
|
||||||
}
|
}
|
||||||
void tls_ref(tls_t *tls)
|
void tls_ref(tls_t *tls)
|
||||||
@ -183,7 +186,14 @@ void tls_unref(tls_t *tls)
|
|||||||
if (tls->refc)
|
if (tls->refc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SSL_shutdown(tls->ssl);
|
if (!tls->no_shutdown) {
|
||||||
|
int ret = SSL_shutdown(tls->ssl);
|
||||||
|
if (ret < 0) {
|
||||||
|
int error = SSL_get_error(tls->ssl, ret);
|
||||||
|
ICECAST_LOG_DEBUG("Shutdown unsuccessful: tls=%p, ret=%i, error=%i", tls, ret, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SSL_free(tls->ssl);
|
SSL_free(tls->ssl);
|
||||||
|
|
||||||
if (tls->ctx)
|
if (tls->ctx)
|
||||||
@ -252,9 +262,11 @@ ssize_t tls_read(tls_t *tls, void *buffer, size_t len)
|
|||||||
|
|
||||||
if (ret <= 0 && !tls->error) {
|
if (ret <= 0 && !tls->error) {
|
||||||
int error = SSL_get_error(tls->ssl, ret);
|
int error = SSL_get_error(tls->ssl, ret);
|
||||||
ICECAST_LOG_DDEBUG("Zero read on TLS (tls=%p, ret=%i, error=%i)", tls, ret, error);
|
ICECAST_LOG_DEBUG("Zero read on TLS (tls=%p, ret=%i, error=%i)", tls, ret, error);
|
||||||
if (error == SSL_ERROR_SYSCALL || error == SSL_ERROR_SSL)
|
if (error == SSL_ERROR_SYSCALL || error == SSL_ERROR_SSL)
|
||||||
tls->error = true;
|
tls->error = true;
|
||||||
|
if (error == SSL_ERROR_SSL)
|
||||||
|
tls->no_shutdown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -270,8 +282,10 @@ ssize_t tls_write(tls_t *tls, const void *buffer, size_t len)
|
|||||||
|
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
switch (SSL_get_error(tls->ssl, ret)) {
|
switch (SSL_get_error(tls->ssl, ret)) {
|
||||||
case SSL_ERROR_SYSCALL:
|
|
||||||
case SSL_ERROR_SSL:
|
case SSL_ERROR_SSL:
|
||||||
|
tls->no_shutdown = true;
|
||||||
|
/* fall thru */
|
||||||
|
case SSL_ERROR_SYSCALL:
|
||||||
return -1;
|
return -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user