ssl_iostream_context_ref(ctx);
*ctx_r = ctx;
- return 0;
+ return 1;
}
int ssl_iostream_client_context_cache_get(const struct ssl_iostream_settings *set,
const char **error_r)
{
const char *error;
- if (ssl_iostream_context_cache_get(set, FALSE, ctx_r, &error) < 0) {
+ int ret;
+ if ((ret = ssl_iostream_context_cache_get(set, FALSE, ctx_r, &error)) < 0) {
*error_r = t_strdup_printf(
"Couldn't initialize SSL client context: %s", error);
return -1;
}
- return 0;
+ return ret;
}
int ssl_iostream_server_context_cache_get(const struct ssl_iostream_settings *set,
const char **error_r)
{
const char *error;
- if (ssl_iostream_context_cache_get(set, TRUE, ctx_r, &error) < 0) {
+ int ret;
+ if ((ret = ssl_iostream_context_cache_get(set, TRUE, ctx_r, &error)) < 0) {
*error_r = t_strdup_printf(
"Couldn't initialize SSL server context: %s", error);
return -1;
}
- return 0;
+ return ret;
}
void ssl_iostream_context_cache_free(void)
/* Persistent cache of ssl_iostream_contexts. The context is permanently stored
until ssl_iostream_context_cache_free() is called. The returned context
- must be unreferenced by the caller. */
+ must be unreferenced by the caller.
+
+ Returns 1 if new context was created, 0 if existing was re-used, and
+ -1 on error.
+*/
int ssl_iostream_client_context_cache_get(const struct ssl_iostream_settings *set,
struct ssl_iostream_context **ctx_r,
const char **error_r);