Apply fast-fail at connect time.
[pgbouncer.git] / include / objects.h
blob25e1420b16de71654f7df6e79c06ba301d506973
1 /*
2 * PgBouncer - Lightweight connection pooler for PostgreSQL.
3 *
4 * Copyright (c) 2007-2009 Marko Kreen, Skype Technologies OÜ
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 extern StatList user_list;
20 extern Tree user_tree;
21 extern StatList pool_list;
22 extern StatList database_list;
23 extern StatList autodatabase_idle_list;
24 extern StatList login_client_list;
25 extern ObjectCache *client_cache;
26 extern ObjectCache *server_cache;
27 extern ObjectCache *db_cache;
28 extern ObjectCache *pool_cache;
29 extern ObjectCache *user_cache;
30 extern ObjectCache *iobuf_cache;
32 PgDatabase *find_database(const char *name);
33 PgUser *find_user(const char *name);
34 PgPool *get_pool(PgDatabase *, PgUser *);
35 bool find_server(PgSocket *client) _MUSTCHECK;
36 bool release_server(PgSocket *server) /* _MUSTCHECK */;
37 bool finish_client_login(PgSocket *client) _MUSTCHECK;
38 bool check_fast_fail(PgSocket *client) _MUSTCHECK;
40 PgSocket * accept_client(int sock, const struct sockaddr_in *addr, bool is_unix) _MUSTCHECK;
41 void disconnect_server(PgSocket *server, bool notify, const char *reason, ...) _PRINTF(3, 4);
42 void disconnect_client(PgSocket *client, bool notify, const char *reason, ...) _PRINTF(3, 4);
44 PgDatabase * add_database(const char *name) _MUSTCHECK;
45 PgDatabase *register_auto_database(const char *name);
46 PgUser * add_user(const char *name, const char *passwd) _MUSTCHECK;
47 PgUser * force_user(PgDatabase *db, const char *username, const char *passwd) _MUSTCHECK;
49 void accept_cancel_request(PgSocket *req);
50 void forward_cancel_request(PgSocket *server);
52 void launch_new_connection(PgPool *pool);
54 bool use_client_socket(int fd, PgAddr *addr, const char *dbname, const char *username, uint64_t ckey, int oldfd, int linkfd,
55 const char *client_end, const char *std_string, const char *datestyle, const char *timezone)
56 _MUSTCHECK;
57 bool use_server_socket(int fd, PgAddr *addr, const char *dbname, const char *username, uint64_t ckey, int oldfd, int linkfd,
58 const char *client_end, const char *std_string, const char *datestyle, const char *timezone)
59 _MUSTCHECK;
61 void activate_client(PgSocket *client);
63 void change_client_state(PgSocket *client, SocketState newstate);
64 void change_server_state(PgSocket *server, SocketState newstate);
66 int get_active_client_count(void);
67 int get_active_server_count(void);
69 void tag_database_dirty(PgDatabase *db);
70 void for_each_server(PgPool *pool, void (*func)(PgSocket *sk));
72 void reuse_just_freed_objects(void);
74 void init_objects(void);
76 void init_caches(void);