dict-connection.c (dovecot-2.3.16) | : | dict-connection.c (dovecot-2.3.17) | ||
---|---|---|---|---|
skipping to change at line 15 | skipping to change at line 15 | |||
#include "ioloop.h" | #include "ioloop.h" | |||
#include "istream.h" | #include "istream.h" | |||
#include "ostream.h" | #include "ostream.h" | |||
#include "llist.h" | #include "llist.h" | |||
#include "strescape.h" | #include "strescape.h" | |||
#include "master-service.h" | #include "master-service.h" | |||
#include "dict-client.h" | #include "dict-client.h" | |||
#include "dict-settings.h" | #include "dict-settings.h" | |||
#include "dict-commands.h" | #include "dict-commands.h" | |||
#include "dict-connection.h" | #include "dict-connection.h" | |||
#include "dict-init-cache.h" | ||||
#include <unistd.h> | #include <unistd.h> | |||
#define DICT_CONN_MAX_PENDING_COMMANDS 1000 | #define DICT_CONN_MAX_PENDING_COMMANDS 1000 | |||
static int dict_connection_dict_init(struct dict_connection *conn); | static int dict_connection_dict_init(struct dict_connection *conn); | |||
static void dict_connection_destroy(struct connection *_conn); | static void dict_connection_destroy(struct connection *_conn); | |||
struct connection_list *dict_connections = NULL; | struct connection_list *dict_connections = NULL; | |||
static struct event_category dict_server_event_category = { | static struct event_category dict_server_event_category = { | |||
skipping to change at line 52 | skipping to change at line 53 | |||
str_to_uint(args[1], &conn->conn.minor_version) < 0 || | str_to_uint(args[1], &conn->conn.minor_version) < 0 || | |||
major != DICT_CLIENT_PROTOCOL_MAJOR_VERSION) | major != DICT_CLIENT_PROTOCOL_MAJOR_VERSION) | |||
return -1; | return -1; | |||
/* check value type */ | /* check value type */ | |||
if (str_to_uint(args[2], &value_type_num) < 0 || | if (str_to_uint(args[2], &value_type_num) < 0 || | |||
value_type_num >= DICT_DATA_TYPE_LAST) | value_type_num >= DICT_DATA_TYPE_LAST) | |||
return -1; | return -1; | |||
conn->value_type = (enum dict_data_type)value_type_num; | conn->value_type = (enum dict_data_type)value_type_num; | |||
conn->username = i_strdup(args[3]); | ||||
conn->name = i_strdup(args[4]); | conn->name = i_strdup(args[4]); | |||
/* try initialize the given dict */ | /* try initialize the given dict */ | |||
if (dict_connection_dict_init(conn) < 0) | if (dict_connection_dict_init(conn) < 0) | |||
return -1; | return -1; | |||
return 1; | return 1; | |||
} | } | |||
static int dict_connection_handshake_line(struct connection *conn, | static int dict_connection_handshake_line(struct connection *conn, | |||
skipping to change at line 91 | skipping to change at line 91 | |||
for (i = 0; i < count; i += 2) { | for (i = 0; i < count; i += 2) { | |||
if (strcmp(strlist[i], conn->name) == 0) | if (strcmp(strlist[i], conn->name) == 0) | |||
break; | break; | |||
} | } | |||
if (i == count) { | if (i == count) { | |||
e_error(conn->conn.event, "Unconfigured dictionary name '%s'", | e_error(conn->conn.event, "Unconfigured dictionary name '%s'", | |||
conn->name); | conn->name); | |||
return -1; | return -1; | |||
} | } | |||
event_set_append_log_prefix(conn->conn.event, | ||||
t_strdup_printf("%s: ", conn->name)); | ||||
event_add_str(conn->conn.event, "dict_name", conn->name); | event_add_str(conn->conn.event, "dict_name", conn->name); | |||
if (conn->username[0] != '\0') | ||||
event_add_str(conn->conn.event, "user", conn->username); | ||||
uri = strlist[i+1]; | uri = strlist[i+1]; | |||
i_zero(&dict_set); | i_zero(&dict_set); | |||
dict_set.value_type = conn->value_type; | ||||
dict_set.username = conn->username; | ||||
dict_set.base_dir = dict_settings->base_dir; | dict_set.base_dir = dict_settings->base_dir; | |||
dict_set.event_parent = conn->conn.event; | dict_set.event_parent = conn->conn.event; | |||
if (dict_init(uri, &dict_set, &conn->dict, &error) < 0) { | if (dict_init_cache_get(conn->name, uri, &dict_set, &conn->dict, &error) < 0) { | |||
/* dictionary initialization failed */ | /* dictionary initialization failed */ | |||
e_error(conn->conn.event, "Failed to initialize dictionary '%s': %s", | e_error(conn->conn.event, "Failed to initialize dictionary '%s': %s", | |||
conn->name, error); | conn->name, error); | |||
return -1; | return -1; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
static int dict_connection_output(struct connection *_conn) | static int dict_connection_output(struct connection *_conn) | |||
{ | { | |||
skipping to change at line 168 | skipping to change at line 166 | |||
i_assert(array_count(&conn->cmds) == 0); | i_assert(array_count(&conn->cmds) == 0); | |||
/* we should have only transactions that haven't been committed or | /* we should have only transactions that haven't been committed or | |||
rollbacked yet. close those before dict is deinitialized. */ | rollbacked yet. close those before dict is deinitialized. */ | |||
if (array_is_created(&conn->transactions)) { | if (array_is_created(&conn->transactions)) { | |||
array_foreach_modifiable(&conn->transactions, transaction) | array_foreach_modifiable(&conn->transactions, transaction) | |||
dict_transaction_rollback(&transaction->ctx); | dict_transaction_rollback(&transaction->ctx); | |||
} | } | |||
if (conn->dict != NULL) | if (conn->dict != NULL) | |||
dict_deinit(&conn->dict); | dict_init_cache_unref(&conn->dict); | |||
if (array_is_created(&conn->transactions)) | if (array_is_created(&conn->transactions)) | |||
array_free(&conn->transactions); | array_free(&conn->transactions); | |||
array_free(&conn->cmds); | array_free(&conn->cmds); | |||
connection_deinit(&conn->conn); | connection_deinit(&conn->conn); | |||
i_free(conn->name); | i_free(conn->name); | |||
i_free(conn->username); | ||||
i_free(conn); | i_free(conn); | |||
master_service_client_connection_destroyed(master_service); | master_service_client_connection_destroyed(master_service); | |||
return FALSE; | return FALSE; | |||
} | } | |||
static int dict_connection_input_line(struct connection *_conn, const char *line ) | static int dict_connection_input_line(struct connection *_conn, const char *line ) | |||
{ | { | |||
struct dict_connection *conn = | struct dict_connection *conn = | |||
container_of(_conn, struct dict_connection, conn); | container_of(_conn, struct dict_connection, conn); | |||
skipping to change at line 246 | skipping to change at line 243 | |||
running. finish them, even if the calling client can't be notified | running. finish them, even if the calling client can't be notified | |||
about whether they succeeded (clients may not even care). | about whether they succeeded (clients may not even care). | |||
flush the command output here in case we were waiting on iteration | flush the command output here in case we were waiting on iteration | |||
output. */ | output. */ | |||
i_stream_close(conn->conn.input); | i_stream_close(conn->conn.input); | |||
o_stream_close(conn->conn.output); | o_stream_close(conn->conn.output); | |||
dict_connection_cmds_output_more(conn); | dict_connection_cmds_output_more(conn); | |||
io_remove(&conn->conn.io); | io_remove(&conn->conn.io); | |||
dict_connection_unref_safe(conn); | dict_connection_unref(conn); | |||
} | } | |||
unsigned int dict_connections_current_count(void) | unsigned int dict_connections_current_count(void) | |||
{ | { | |||
return dict_connections->connections_count; | return dict_connections->connections_count; | |||
} | } | |||
void dict_connections_destroy_all(void) | void dict_connections_destroy_all(void) | |||
{ | { | |||
connection_list_deinit(&dict_connections); | connection_list_deinit(&dict_connections); | |||
End of changes. 9 change blocks. | ||||
9 lines changed or deleted | 6 lines changed or added |