return 1;
}
-static int set_trace_data(int category, BIO **channel,
+static int set_trace_data(int category, int type, BIO **channel,
const char **prefix, const char **suffix,
int (*attach_cb)(int, int, const void *),
int (*detach_cb)(int, int, const void *))
if (channel != NULL && curr_channel != NULL) {
BIO_free(curr_channel);
+ trace_channels[category].type = 0;
trace_channels[category].bio = NULL;
}
/* Before running callbacks are done, set new data where appropriate */
if (channel != NULL && *channel != NULL) {
+ trace_channels[category].type = type;
trace_channels[category].bio = *channel;
}
/* We force the TRACE category to be treated last */
if (category == OSSL_TRACE_CATEGORY_TRACE)
continue;
- set_trace_data(category, &channel, &prefix, &suffix,
+ set_trace_data(category, 0, &channel, &prefix, &suffix,
trace_attach_cb, trace_detach_cb);
}
- set_trace_data(OSSL_TRACE_CATEGORY_TRACE, &channel, &prefix, &suffix,
+ set_trace_data(OSSL_TRACE_CATEGORY_TRACE, 0, &channel,
+ &prefix, &suffix,
trace_attach_cb, trace_detach_cb);
CRYPTO_THREAD_lock_free(trace_lock);
#endif
{
#ifndef OPENSSL_NO_TRACE
if (category < 0 || category >= OSSL_TRACE_CATEGORY_NUM
- || !set_trace_data(category, &channel, NULL, NULL,
+ || !set_trace_data(category, SIMPLE_CHANNEL, &channel, NULL, NULL,
trace_attach_cb, trace_detach_cb))
return 0;
-
- trace_channels[category].type = SIMPLE_CHANNEL;
#endif
return 1;
}
BIO_set_data(channel, trace_data);
}
- if (!set_trace_data(category, &channel, NULL, NULL,
+ if (!set_trace_data(category, CALLBACK_CHANNEL, &channel, NULL, NULL,
trace_attach_w_callback_cb, trace_detach_cb))
goto err;
- trace_channels[category].type = CALLBACK_CHANNEL;
goto done;
err:
#ifndef OPENSSL_NO_TRACE
if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM)
- return set_trace_data(category, NULL, &prefix, NULL,
+ return set_trace_data(category, 0, NULL, &prefix, NULL,
trace_attach_cb, trace_detach_cb);
rv = 0;
#endif
#ifndef OPENSSL_NO_TRACE
if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM)
- return set_trace_data(category, NULL, NULL, &suffix,
+ return set_trace_data(category, 0, NULL, NULL, &suffix,
trace_attach_cb, trace_detach_cb);
rv = 0;
#endif