Skip to content

Commit

Permalink
auth-policy: Move callback to helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Feb 21, 2019
1 parent 16fbc27 commit e1fa186
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/auth/auth-policy.c
Expand Up @@ -247,6 +247,13 @@ void auth_policy_finish(struct policy_lookup_ctx *context)
auth_request_unref(&context->request);
}

static
void auth_policy_callback(struct policy_lookup_ctx *context)
{
if (context->callback != NULL)
context->callback(context->result, context->callback_context);
}

static
void auth_policy_parse_response(struct policy_lookup_ctx *context)
{
Expand Down Expand Up @@ -332,9 +339,7 @@ void auth_policy_parse_response(struct policy_lookup_ctx *context)
(context->message!=NULL?context->message:""));
}

if (context->callback != NULL) {
context->callback(context->result, context->callback_context);
}
auth_policy_callback(context);
}

static
Expand All @@ -349,17 +354,15 @@ void auth_policy_process_response(const struct http_response *response,
auth_request_log_error(context->request, "policy",
"Policy server HTTP error: %s",
http_response_get_message(response));
if (context->callback != NULL)
context->callback(context->result, context->callback_context);
auth_policy_callback(context);
return;
}

if (response->payload == NULL) {
if (context->expect_result)
auth_request_log_error(context->request, "policy",
"Policy server result was empty");
if (context->callback != NULL)
context->callback(context->result, context->callback_context);
auth_policy_callback(context);
return;
}

Expand All @@ -371,8 +374,7 @@ void auth_policy_process_response(const struct http_response *response,
} else {
auth_request_log_debug(context->request, "policy",
"Policy response %d", context->result);
if (context->callback != NULL)
context->callback(context->result, context->callback_context);
auth_policy_callback(context);
}
}

Expand Down

0 comments on commit e1fa186

Please sign in to comment.