Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaUnisikhin committed Feb 12, 2024
1 parent 716551e commit f9160fe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
34 changes: 17 additions & 17 deletions sources/config_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,7 @@ od_config_reader_ldap_storage_credentials(od_config_reader_t *reader,
static int od_config_reader_rule_settings(od_config_reader_t *reader,
od_rule_t *rule,
od_extention_t *extentions,
od_storage_watchdog_t *watchdog,
od_group_t *group)
od_storage_watchdog_t *watchdog)
{
for (;;) {
od_token_t token;
Expand Down Expand Up @@ -1671,14 +1670,14 @@ static int od_config_reader_rule_settings(od_config_reader_t *reader,
continue;
/* group_query */
case OD_LGROUP_QUERY:
if (group == NULL) {
if (rule->group == NULL) {
od_config_reader_error(
reader, NULL,
"group settings specified for non-group route");
return NOT_OK_RESPONSE;
}
if (!od_config_reader_string(reader,
&group->group_query)) {
if (!od_config_reader_string(
reader, &rule->group->group_query)) {
return NOT_OK_RESPONSE;
}
continue;
Expand Down Expand Up @@ -1744,13 +1743,12 @@ static int od_config_reader_route(od_config_reader_t *reader, char *db_name,
return NOT_OK_RESPONSE;

/* unreach */
return od_config_reader_rule_settings(reader, rule, extentions, NULL,
NULL);
return od_config_reader_rule_settings(reader, rule, extentions, NULL);
}

static int od_config_reader_group(od_config_reader_t *reader, char *db_name,
int db_name_len, int db_is_default,
od_extention_t *extentions)
od_group_t *group, od_extention_t *extentions)
{
/* group name */
char *group_name = NULL;
Expand Down Expand Up @@ -1787,10 +1785,7 @@ static int od_config_reader_group(od_config_reader_t *reader, char *db_name,
if (rule->db_name == NULL)
return NOT_OK_RESPONSE;

od_group_t *group;
group = od_rules_group_allocate(reader->global);
group->group_name = strdup(group_name);
group->group_name_len = strlen(group->group_name);
group->route_usr = strdup(rule->user_name);
group->route_db = strdup(rule->db_name);
rule->group = group;
Expand All @@ -1800,8 +1795,8 @@ static int od_config_reader_group(od_config_reader_t *reader, char *db_name,
return NOT_OK_RESPONSE;

/* unreach */
if (od_config_reader_rule_settings(reader, rule, extentions, NULL,
group) == NOT_OK_RESPONSE) {
if (od_config_reader_rule_settings(reader, rule, extentions, NULL) ==
NOT_OK_RESPONSE) {
goto error;
}

Expand Down Expand Up @@ -1858,8 +1853,8 @@ static inline int od_config_reader_watchdog(od_config_reader_t *reader,
return NOT_OK_RESPONSE;

/* unreach */
if (od_config_reader_rule_settings(reader, rule, extentions, watchdog,
NULL) == NOT_OK_RESPONSE) {
if (od_config_reader_rule_settings(reader, rule, extentions,
watchdog) == NOT_OK_RESPONSE) {
return NOT_OK_RESPONSE;
}

Expand Down Expand Up @@ -2140,10 +2135,15 @@ static int od_config_reader_database(od_config_reader_t *reader,
if (rc == -1)
goto error;
continue;
case OD_LGROUP:
case OD_LGROUP:;
od_group_t *group;
group = od_rules_group_allocate(reader->global);
if (group == NULL) {
return NOT_OK_RESPONSE;
}
rc = od_config_reader_group(reader, db_name,
db_name_len, db_is_default,
extentions);
group, extentions);
if (rc == -1)
goto error;
continue;
Expand Down
3 changes: 0 additions & 3 deletions sources/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ void od_group_qry_format(char *qry, char *fmt, ...)
va_start(args, fmt);
int len = od_vsnprintf(qry, OD_QRY_MAX_SZ, fmt, args);
va_end(args);

/* dirty hack */
qry[len] = '\0';
}

int od_group_parse_val_datarow(machine_msg_t *msg, int *is_group_member)
Expand Down
5 changes: 3 additions & 2 deletions sources/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Scalable PostgreSQL connection pooler.
*/

#ifndef ODYSSEY_GROUP_CHECK_ITER_INTERVAL
#define ODYSSEY_GROUP_CHECK_ITER_INTERVAL 500 // ms

typedef struct od_group od_group_t;
Expand All @@ -14,9 +15,7 @@ struct od_group {

char *storage_user;
char *storage_db;

char *group_name;
int group_name_len;

char *group_query;
int check_retry;
Expand All @@ -30,3 +29,5 @@ struct od_group {
int od_group_free(od_group_t *);
void od_group_qry_format(char *, char *, ...);
int od_group_parse_val_datarow(machine_msg_t *, int *);

#endif /* ODYSSEY_GROUP_CHECK_ITER_INTERVAL */
4 changes: 1 addition & 3 deletions sources/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ od_group_t *od_rules_group_allocate(od_global_t *global)
{
/* Allocate and force defaults */
od_group_t *group;
group = (od_group_t *)malloc(sizeof(*group));
group = calloc(1, sizeof(*group));
if (group == NULL)
return NULL;
memset(group, 0, sizeof(*group));
group->global = global;
group->check_retry = 10;
group->online = 1;
Expand Down Expand Up @@ -301,7 +300,6 @@ void od_rules_group_checker_run(void *arg)
sizeof(char));
od_group_qry_format(qry, group->group_query,
rule->user_name);

msg = od_query_do(server, "group_checker", qry,
NULL);
free(qry);
Expand Down

0 comments on commit f9160fe

Please sign in to comment.