1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen#ifndef DICT_CONNECTION_H
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen#define DICT_CONNECTION_H
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen#include "dict.h"
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainenstruct dict_connection_transaction {
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen unsigned int id;
3954326e793bdef1e94e0ad781ed6cc7e48beebbTimo Sirainen struct dict_connection *conn;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct dict_transaction_context *ctx;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen};
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainenstruct dict_connection {
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct dict_connection *prev, *next;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct dict_server *server;
ac00e30516d93d289c71bd59f338c26693329e67Timo Sirainen int refcount;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen char *username;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen char *name;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct dict *dict;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen enum dict_data_type value_type;
8e1491e4924e3f9fc474a99438b6297b8d1ce1f3Timo Sirainen unsigned int minor_version;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen int fd;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct io *io;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct istream *input;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen struct ostream *output;
1a883718249b8db128a105ee7f03293873f1f9c5Timo Sirainen struct timeout *to_input;
f6d8250f99520eac003da742a5f34abd2b537c38Timo Sirainen struct timeout *to_unref;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen /* There are only a few transactions per client, so keeping them in
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen array is fast enough */
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen ARRAY(struct dict_connection_transaction) transactions;
1a883718249b8db128a105ee7f03293873f1f9c5Timo Sirainen ARRAY(struct dict_connection_cmd *) cmds;
44c54229a117b8dab05eaff9c54ba61fbae9a39fTimo Sirainen unsigned int async_id_counter;
ac00e30516d93d289c71bd59f338c26693329e67Timo Sirainen
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool destroyed:1;
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen};
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainenstruct dict_connection *dict_connection_create(int fd);
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainenvoid dict_connection_destroy(struct dict_connection *conn);
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
ac00e30516d93d289c71bd59f338c26693329e67Timo Sirainenvoid dict_connection_ref(struct dict_connection *conn);
ac00e30516d93d289c71bd59f338c26693329e67Timo Sirainenbool dict_connection_unref(struct dict_connection *conn);
f6d8250f99520eac003da742a5f34abd2b537c38Timo Sirainenvoid dict_connection_unref_safe(struct dict_connection *conn);
ac00e30516d93d289c71bd59f338c26693329e67Timo Sirainen
1a883718249b8db128a105ee7f03293873f1f9c5Timo Sirainenvoid dict_connection_continue_input(struct dict_connection *conn);
1a883718249b8db128a105ee7f03293873f1f9c5Timo Sirainen
cbe49ba128638e63395aedaa2144087c89835633Timo Sirainenunsigned int dict_connections_current_count(void);
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainenvoid dict_connections_destroy_all(void);
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen
1ea214b620715aa8b213c5686383b821e720fe42Timo Sirainen#endif