Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib-dict/dict-client.c @ 8660:d8a56ea9f408 HEAD
Added dict_transaction_commit_async().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 19 Jan 2009 16:03:25 -0500 |
parents | b9faf4db2a9f |
children | 446775a31754 |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8105
diff
changeset
|
1 /* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */ |
3793 | 2 |
3 #include "lib.h" | |
4 #include "str.h" | |
5 #include "network.h" | |
6 #include "istream.h" | |
7 #include "ostream.h" | |
8 #include "dict-private.h" | |
9 #include "dict-client.h" | |
10 | |
11 #include <unistd.h> | |
12 #include <fcntl.h> | |
13 | |
14 struct client_dict { | |
15 struct dict dict; | |
16 | |
17 pool_t pool; | |
18 int fd; | |
19 const char *uri; | |
20 const char *username; | |
21 const char *path; | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
22 enum dict_data_type value_type; |
3793 | 23 |
7008
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
24 time_t last_connect_try; |
3793 | 25 struct istream *input; |
26 struct ostream *output; | |
27 | |
8660
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
28 unsigned int skip_lines; |
3793 | 29 unsigned int connect_counter; |
30 unsigned int transaction_id_counter; | |
31 | |
32 unsigned int in_iteration:1; | |
33 unsigned int handshaked:1; | |
34 }; | |
35 | |
36 struct client_dict_iterate_context { | |
37 struct dict_iterate_context ctx; | |
38 | |
39 pool_t pool; | |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3858
diff
changeset
|
40 bool failed; |
3793 | 41 }; |
42 | |
43 struct client_dict_transaction_context { | |
44 struct dict_transaction_context ctx; | |
45 | |
46 unsigned int id; | |
47 unsigned int connect_counter; | |
48 | |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
49 unsigned int failed:1; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
50 unsigned int sent_begin:1; |
3793 | 51 }; |
52 | |
53 static int client_dict_connect(struct client_dict *dict); | |
54 static void client_dict_disconnect(struct client_dict *dict); | |
55 | |
56 const char *dict_client_escape(const char *src) | |
57 { | |
58 const char *p; | |
59 string_t *dest; | |
60 | |
61 /* first do a quick lookup to see if there's anything to escape. | |
62 probably not. */ | |
63 for (p = src; *p != '\0'; p++) { | |
64 if (*p == '\t' || *p == '\n' || *p == '\001') | |
65 break; | |
66 } | |
67 | |
68 if (*p == '\0') | |
69 return src; | |
70 | |
71 dest = t_str_new(256); | |
72 str_append_n(dest, src, p - src); | |
73 | |
3858 | 74 for (; *p != '\0'; p++) { |
3793 | 75 switch (*p) { |
76 case '\t': | |
77 str_append_c(dest, '\001'); | |
78 str_append_c(dest, 't'); | |
79 break; | |
80 case '\n': | |
81 str_append_c(dest, '\001'); | |
82 str_append_c(dest, 'n'); | |
83 break; | |
84 case '\001': | |
85 str_append_c(dest, '\001'); | |
86 str_append_c(dest, '1'); | |
87 break; | |
88 default: | |
89 str_append_c(dest, *p); | |
90 break; | |
91 } | |
92 } | |
93 return str_c(dest); | |
94 } | |
95 | |
96 const char *dict_client_unescape(const char *src) | |
97 { | |
98 const char *p; | |
99 string_t *dest; | |
100 | |
101 /* first do a quick lookup to see if there's anything to unescape. | |
102 probably not. */ | |
103 for (p = src; *p != '\0'; p++) { | |
104 if (*p == '\001') | |
105 break; | |
106 } | |
107 | |
108 if (*p == '\0') | |
109 return src; | |
110 | |
111 dest = t_str_new(256); | |
112 str_append_n(dest, src, p - src); | |
113 for (; *p != '\0'; p++) { | |
114 if (*p != '\001') | |
115 str_append_c(dest, *p); | |
116 else if (p[1] != '\0') { | |
117 p++; | |
118 switch (*p) { | |
119 case '1': | |
120 str_append_c(dest, '\001'); | |
121 break; | |
122 case 't': | |
123 str_append_c(dest, '\t'); | |
124 break; | |
125 case 'n': | |
126 str_append_c(dest, '\n'); | |
127 break; | |
128 } | |
129 } | |
130 } | |
131 return str_c(dest); | |
132 } | |
133 | |
134 static int client_dict_send_query(struct client_dict *dict, const char *query) | |
135 { | |
4368 | 136 if (dict->output == NULL) { |
137 /* not connected currently */ | |
138 if (client_dict_connect(dict) < 0) | |
139 return -1; | |
140 } | |
141 | |
3793 | 142 if (o_stream_send_str(dict->output, query) < 0 || |
143 o_stream_flush(dict->output) < 0) { | |
144 /* Send failed */ | |
145 if (!dict->handshaked) { | |
146 /* we're trying to send hello, don't try to reconnect */ | |
147 return -1; | |
148 } | |
149 | |
150 /* Reconnect and try again. */ | |
151 client_dict_disconnect(dict); | |
152 if (client_dict_connect(dict) < 0) | |
153 return -1; | |
154 | |
155 if (o_stream_send_str(dict->output, query) < 0 || | |
156 o_stream_flush(dict->output) < 0) { | |
157 i_error("write(%s) failed: %m", dict->path); | |
158 return -1; | |
159 } | |
160 } | |
161 return 0; | |
162 } | |
163 | |
4368 | 164 static int |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
165 client_dict_transaction_send_begin(struct client_dict_transaction_context *ctx) |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
166 { |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
167 struct client_dict *dict = (struct client_dict *)ctx->ctx.dict; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
168 |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
169 if (ctx->failed) |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
170 return -1; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
171 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
172 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
173 const char *query; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
174 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
175 query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_BEGIN, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
176 ctx->id); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
177 if (client_dict_send_query(dict, query) < 0) |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
178 ctx->failed = TRUE; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
179 else |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
180 ctx->connect_counter = dict->connect_counter; |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
181 } T_END; |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
182 |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
183 return ctx->failed ? -1 : 0; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
184 } |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
185 |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
186 static int |
4368 | 187 client_dict_send_transaction_query(struct client_dict_transaction_context *ctx, |
188 const char *query) | |
189 { | |
190 struct client_dict *dict = (struct client_dict *)ctx->ctx.dict; | |
191 | |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
192 if (!ctx->sent_begin) { |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
193 if (client_dict_transaction_send_begin(ctx) < 0) |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
194 return -1; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
195 ctx->sent_begin = TRUE; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
196 } |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
197 |
4385 | 198 if (ctx->connect_counter != dict->connect_counter || ctx->failed) |
199 return -1; | |
200 | |
201 if (dict->output == NULL) { | |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
202 /* not connected, this'll fail */ |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
203 return -1; |
4385 | 204 } |
205 | |
4368 | 206 if (o_stream_send_str(dict->output, query) < 0 || |
207 o_stream_flush(dict->output) < 0) { | |
208 /* Send failed. Our transactions have died, so don't even try | |
209 to re-send the command */ | |
210 ctx->failed = TRUE; | |
211 client_dict_disconnect(dict); | |
212 return -1; | |
213 } | |
214 return 0; | |
215 } | |
216 | |
3793 | 217 static char *client_dict_read_line(struct client_dict *dict) |
218 { | |
219 char *line; | |
220 int ret; | |
221 | |
4519
4be4c887deb7
dict proxy: Dictionary iteration was broken.
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
222 line = i_stream_next_line(dict->input); |
4be4c887deb7
dict proxy: Dictionary iteration was broken.
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
223 if (line != NULL) |
4be4c887deb7
dict proxy: Dictionary iteration was broken.
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
224 return line; |
4be4c887deb7
dict proxy: Dictionary iteration was broken.
Timo Sirainen <tss@iki.fi>
parents:
4517
diff
changeset
|
225 |
3793 | 226 while ((ret = i_stream_read(dict->input)) > 0) { |
227 line = i_stream_next_line(dict->input); | |
8660
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
228 if (line != NULL) { |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
229 if (dict->skip_lines == 0) |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
230 return line; |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
231 /* ignore this reply and wait for the next line */ |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
232 dict->skip_lines--; |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
233 } |
3793 | 234 } |
6525 | 235 i_assert(ret < 0); |
3793 | 236 |
6525 | 237 if (ret == -2) |
238 i_error("read(%s) returned too much data", dict->path); | |
7988
e069e4c221e1
dict-proxy: Fix error message if remote disconnects.
Timo Sirainen <tss@iki.fi>
parents:
7969
diff
changeset
|
239 else if (dict->input->stream_errno == 0) |
e069e4c221e1
dict-proxy: Fix error message if remote disconnects.
Timo Sirainen <tss@iki.fi>
parents:
7969
diff
changeset
|
240 i_error("read(%s) failed: Remote disconnected", dict->path); |
7418
a18f7f0dcff5
Reverted last error handling change, it can't happen after all.
Timo Sirainen <tss@iki.fi>
parents:
7417
diff
changeset
|
241 else |
7417 | 242 i_error("read(%s) failed: %m", dict->path); |
3793 | 243 return NULL; |
244 } | |
245 | |
246 static int client_dict_connect(struct client_dict *dict) | |
247 { | |
248 const char *query; | |
249 | |
250 i_assert(dict->fd == -1); | |
251 | |
7008
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
252 if (dict->last_connect_try == ioloop_time) { |
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
253 /* Try again later */ |
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
254 return -1; |
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
255 } |
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
256 dict->last_connect_try = ioloop_time; |
6950bb5e7921
Don't try to reconnect more often than once/sec.
Timo Sirainen <tss@iki.fi>
parents:
7007
diff
changeset
|
257 |
3793 | 258 dict->fd = net_connect_unix(dict->path); |
259 if (dict->fd == -1) { | |
260 i_error("net_connect_unix(%s) failed: %m", dict->path); | |
261 return -1; | |
262 } | |
263 | |
264 /* Dictionary lookups are blocking */ | |
265 net_set_nonblock(dict->fd, FALSE); | |
266 | |
6162
896cc473c1f0
Renamed i_stream_create_file() to i_stream_create_fd().
Timo Sirainen <tss@iki.fi>
parents:
6161
diff
changeset
|
267 dict->input = i_stream_create_fd(dict->fd, (size_t)-1, FALSE); |
7969
2cd775b45b0c
Set dict proxy istream nonblocking so EINTR (^C) won't crash.
Timo Sirainen <tss@iki.fi>
parents:
7418
diff
changeset
|
268 dict->input->blocking = TRUE; |
6161
c62f7ee79446
Split o_stream_create_file() to _create_fd() and _create_fd_file().
Timo Sirainen <tss@iki.fi>
parents:
6142
diff
changeset
|
269 dict->output = o_stream_create_fd(dict->fd, 4096, FALSE); |
3793 | 270 dict->transaction_id_counter = 0; |
271 | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
272 query = t_strdup_printf("%c%u\t%u\t%d\t%s\t%s\n", |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
273 DICT_PROTOCOL_CMD_HELLO, |
3793 | 274 DICT_CLIENT_PROTOCOL_MAJOR_VERSION, |
275 DICT_CLIENT_PROTOCOL_MINOR_VERSION, | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
276 dict->value_type, dict->username, dict->uri); |
3793 | 277 if (client_dict_send_query(dict, query) < 0) { |
278 client_dict_disconnect(dict); | |
279 return -1; | |
280 } | |
281 | |
282 dict->handshaked = TRUE; | |
283 return 0; | |
284 } | |
285 | |
286 static void client_dict_disconnect(struct client_dict *dict) | |
287 { | |
288 dict->connect_counter++; | |
289 dict->handshaked = FALSE; | |
290 | |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
291 if (dict->input != NULL) |
4070
71b8faa84ec6
Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents:
3990
diff
changeset
|
292 i_stream_destroy(&dict->input); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
293 if (dict->output != NULL) |
4070
71b8faa84ec6
Added i_stream_destroy() and o_stream_destroy() and used them instead of
Timo Sirainen <tss@iki.fi>
parents:
3990
diff
changeset
|
294 o_stream_destroy(&dict->output); |
3793 | 295 |
296 if (dict->fd != -1) { | |
297 if (close(dict->fd) < 0) | |
298 i_error("close(%s) failed: %m", dict->path); | |
299 dict->fd = -1; | |
300 } | |
301 } | |
302 | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
303 static struct dict * |
4517
e661182eab75
Berkeley DB dict support is now enabled only when using --with-db configure option.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4516
diff
changeset
|
304 client_dict_init(struct dict *driver, const char *uri, |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
305 enum dict_data_type value_type, const char *username) |
3793 | 306 { |
307 struct client_dict *dict; | |
3967
6fabe878c46d
Dictionary takes now a username parameter, which is used for private
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
308 const char *dest_uri; |
3793 | 309 pool_t pool; |
310 | |
3967
6fabe878c46d
Dictionary takes now a username parameter, which is used for private
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
311 /* uri = [<path>] ":" <uri> */ |
3793 | 312 dest_uri = strchr(uri, ':'); |
313 if (dest_uri == NULL) { | |
314 i_error("dict-client: Invalid URI: %s", uri); | |
315 return NULL; | |
316 } | |
317 | |
318 pool = pool_alloconly_create("client dict", 1024); | |
319 dict = p_new(pool, struct client_dict, 1); | |
320 dict->pool = pool; | |
4517
e661182eab75
Berkeley DB dict support is now enabled only when using --with-db configure option.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4516
diff
changeset
|
321 dict->dict = *driver; |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
322 dict->value_type = value_type; |
3967
6fabe878c46d
Dictionary takes now a username parameter, which is used for private
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
323 dict->username = p_strdup(pool, username); |
3793 | 324 |
325 dict->fd = -1; | |
326 | |
3967
6fabe878c46d
Dictionary takes now a username parameter, which is used for private
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
327 if (*uri != ':') { |
3793 | 328 /* path given */ |
3967
6fabe878c46d
Dictionary takes now a username parameter, which is used for private
Timo Sirainen <tss@iki.fi>
parents:
3879
diff
changeset
|
329 dict->path = p_strdup_until(pool, uri, dest_uri); |
3793 | 330 } else { |
331 dict->path = DEFAULT_DICT_SERVER_SOCKET_PATH; | |
332 } | |
333 dict->uri = p_strdup(pool, dest_uri + 1); | |
334 return &dict->dict; | |
335 } | |
336 | |
337 static void client_dict_deinit(struct dict *_dict) | |
338 { | |
339 struct client_dict *dict = (struct client_dict *)_dict; | |
340 | |
341 client_dict_disconnect(dict); | |
6428
7cad076906eb
pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
342 pool_unref(&dict->pool); |
3793 | 343 } |
344 | |
345 static int client_dict_lookup(struct dict *_dict, pool_t pool, | |
346 const char *key, const char **value_r) | |
347 { | |
348 struct client_dict *dict = (struct client_dict *)_dict; | |
349 const char *line; | |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
350 int ret; |
3793 | 351 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
352 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
353 const char *query; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
354 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
355 query = t_strdup_printf("%c%s\n", DICT_PROTOCOL_CMD_LOOKUP, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
356 dict_client_escape(key)); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
357 ret = client_dict_send_query(dict, query); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
358 } T_END; |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
359 if (ret < 0) |
3793 | 360 return -1; |
361 | |
362 /* read reply */ | |
363 line = client_dict_read_line(dict); | |
364 if (line == NULL) | |
365 return -1; | |
366 | |
367 if (*line == DICT_PROTOCOL_REPLY_OK) { | |
368 *value_r = p_strdup(pool, dict_client_unescape(line + 1)); | |
369 return 1; | |
370 } else { | |
371 *value_r = NULL; | |
372 return *line == DICT_PROTOCOL_REPLY_NOTFOUND ? 0 : -1; | |
373 } | |
374 } | |
375 | |
376 static struct dict_iterate_context * | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
377 client_dict_iterate_init(struct dict *_dict, const char *path, |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
378 enum dict_iterate_flags flags) |
3793 | 379 { |
380 struct client_dict *dict = (struct client_dict *)_dict; | |
381 struct client_dict_iterate_context *ctx; | |
382 | |
383 if (dict->in_iteration) | |
384 i_panic("dict-client: Only one iteration supported"); | |
385 dict->in_iteration = TRUE; | |
386 | |
387 ctx = i_new(struct client_dict_iterate_context, 1); | |
388 ctx->ctx.dict = _dict; | |
389 ctx->pool = pool_alloconly_create("client dict iteration", 512); | |
390 | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
391 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
392 const char *query; |
3793 | 393 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
394 query = t_strdup_printf("%c%d\t%s\n", DICT_PROTOCOL_CMD_ITERATE, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
395 flags, dict_client_escape(path)); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
396 if (client_dict_send_query(dict, query) < 0) |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
397 ctx->failed = TRUE; |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
398 } T_END; |
3793 | 399 return &ctx->ctx; |
400 } | |
401 | |
402 static int client_dict_iterate(struct dict_iterate_context *_ctx, | |
403 const char **key_r, const char **value_r) | |
404 { | |
405 struct client_dict_iterate_context *ctx = | |
406 (struct client_dict_iterate_context *)_ctx; | |
407 struct client_dict *dict = (struct client_dict *)_ctx->dict; | |
408 char *line, *value; | |
409 | |
410 if (ctx->failed) | |
411 return -1; | |
412 | |
413 /* read next reply */ | |
414 line = client_dict_read_line(dict); | |
415 if (line == NULL) | |
416 return -1; | |
417 | |
418 if (*line == '\0') { | |
419 /* end of iteration */ | |
420 return 0; | |
421 } | |
422 | |
423 /* line contains key \t value */ | |
424 p_clear(ctx->pool); | |
425 | |
426 value = strchr(line, '\t'); | |
427 if (value == NULL) { | |
428 /* broken protocol */ | |
429 i_error("dict client (%s) sent broken reply", dict->path); | |
430 return -1; | |
431 } | |
432 *value++ = '\0'; | |
433 | |
434 *key_r = p_strdup(ctx->pool, dict_client_unescape(line)); | |
435 *value_r = p_strdup(ctx->pool, dict_client_unescape(value)); | |
436 return 1; | |
437 } | |
438 | |
439 static void client_dict_iterate_deinit(struct dict_iterate_context *_ctx) | |
440 { | |
441 struct client_dict *dict = (struct client_dict *)_ctx->dict; | |
442 struct client_dict_iterate_context *ctx = | |
443 (struct client_dict_iterate_context *)_ctx; | |
444 | |
6428
7cad076906eb
pool_unref() now takes ** pointer.
Timo Sirainen <tss@iki.fi>
parents:
6162
diff
changeset
|
445 pool_unref(&ctx->pool); |
3793 | 446 i_free(ctx); |
8105
ad9ad222729c
Calling dict_iterate_init() multiple times for a dict assert-crashed.
Timo Sirainen <tss@iki.fi>
parents:
7988
diff
changeset
|
447 dict->in_iteration = FALSE; |
3793 | 448 } |
449 | |
450 static struct dict_transaction_context * | |
451 client_dict_transaction_init(struct dict *_dict) | |
452 { | |
453 struct client_dict *dict = (struct client_dict *)_dict; | |
454 struct client_dict_transaction_context *ctx; | |
455 | |
456 ctx = i_new(struct client_dict_transaction_context, 1); | |
457 ctx->ctx.dict = _dict; | |
458 ctx->id = ++dict->transaction_id_counter; | |
4368 | 459 |
3793 | 460 return &ctx->ctx; |
461 } | |
462 | |
8660
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
463 static int client_dict_transaction_commit(struct dict_transaction_context *_ctx, |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
464 bool async) |
3793 | 465 { |
466 struct client_dict_transaction_context *ctx = | |
467 (struct client_dict_transaction_context *)_ctx; | |
468 struct client_dict *dict = (struct client_dict *)_ctx->dict; | |
469 int ret = ctx->failed ? -1 : 0; | |
470 | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
471 if (ctx->sent_begin) T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
472 const char *query, *line; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
473 |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
474 query = t_strdup_printf("%c%u\n", !ctx->failed ? |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
475 DICT_PROTOCOL_CMD_COMMIT : |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
476 DICT_PROTOCOL_CMD_ROLLBACK, ctx->id); |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
477 if (client_dict_send_transaction_query(ctx, query) < 0) |
3793 | 478 ret = -1; |
8660
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
479 else if (ret < 0) { |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
480 /* rollback sent, it has no reply */ |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
481 } else if (async) { |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
482 /* don't wait for the reply. if we read it later, |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
483 ignore it. */ |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
484 dict->skip_lines++; |
d8a56ea9f408
Added dict_transaction_commit_async().
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
485 } else { |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
486 /* read reply */ |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
487 line = client_dict_read_line(dict); |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
488 if (line == NULL || *line != DICT_PROTOCOL_REPLY_OK) |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
489 ret = -1; |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
490 } |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
491 } T_END; |
3793 | 492 |
493 i_free(ctx); | |
494 return ret; | |
495 } | |
496 | |
497 static void | |
498 client_dict_transaction_rollback(struct dict_transaction_context *_ctx) | |
499 { | |
500 struct client_dict_transaction_context *ctx = | |
501 (struct client_dict_transaction_context *)_ctx; | |
502 | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
503 if (ctx->sent_begin) T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
504 const char *query; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
505 |
4512
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
506 query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_ROLLBACK, |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
507 ctx->id); |
b5d4c1e9a492
Delay sending the transaction begin command to server until the first
Timo Sirainen <tss@iki.fi>
parents:
4385
diff
changeset
|
508 (void)client_dict_send_transaction_query(ctx, query); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
509 } T_END; |
4385 | 510 |
3793 | 511 i_free(ctx); |
512 } | |
513 | |
514 static void client_dict_set(struct dict_transaction_context *_ctx, | |
515 const char *key, const char *value) | |
516 { | |
517 struct client_dict_transaction_context *ctx = | |
518 (struct client_dict_transaction_context *)_ctx; | |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
519 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
520 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
521 const char *query; |
3793 | 522 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
523 query = t_strdup_printf("%c%u\t%s\t%s\n", |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
524 DICT_PROTOCOL_CMD_SET, ctx->id, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
525 dict_client_escape(key), |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
526 dict_client_escape(value)); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
527 (void)client_dict_send_transaction_query(ctx, query); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
528 } T_END; |
3793 | 529 } |
530 | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
531 static void client_dict_unset(struct dict_transaction_context *_ctx, |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
532 const char *key) |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
533 { |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
534 struct client_dict_transaction_context *ctx = |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
535 (struct client_dict_transaction_context *)_ctx; |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
536 |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
537 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
538 const char *query; |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
539 |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
540 query = t_strdup_printf("%c%u\t%s\n", |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
541 DICT_PROTOCOL_CMD_UNSET, ctx->id, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
542 dict_client_escape(key)); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
543 (void)client_dict_send_transaction_query(ctx, query); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
544 } T_END; |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
545 } |
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
546 |
3793 | 547 static void client_dict_atomic_inc(struct dict_transaction_context *_ctx, |
3990
e2e6919c6c4d
LF wasn't sent at the end of all commands.
Timo Sirainen <tss@iki.fi>
parents:
3967
diff
changeset
|
548 const char *key, long long diff) |
3793 | 549 { |
550 struct client_dict_transaction_context *ctx = | |
551 (struct client_dict_transaction_context *)_ctx; | |
552 | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
553 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
554 const char *query; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
555 query = t_strdup_printf("%c%u\t%s\t%lld\n", |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
556 DICT_PROTOCOL_CMD_ATOMIC_INC, |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
557 ctx->id, dict_client_escape(key), diff); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6525
diff
changeset
|
558 (void)client_dict_send_transaction_query(ctx, query); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
559 } T_END; |
3793 | 560 } |
561 | |
4517
e661182eab75
Berkeley DB dict support is now enabled only when using --with-db configure option.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4516
diff
changeset
|
562 struct dict dict_driver_client = { |
3793 | 563 MEMBER(name) "proxy", |
564 | |
565 { | |
566 client_dict_init, | |
567 client_dict_deinit, | |
568 client_dict_lookup, | |
569 client_dict_iterate_init, | |
570 client_dict_iterate, | |
571 client_dict_iterate_deinit, | |
572 client_dict_transaction_init, | |
573 client_dict_transaction_commit, | |
574 client_dict_transaction_rollback, | |
575 client_dict_set, | |
4516
aa2f73a4df26
Dictionary changes: Added support for defining value's type. Key is still always a string. Added support for sorting the iteration replies. Added dict_unset(). Added Berkeley DB support. Most of the code written by Tianyan Liu.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4512
diff
changeset
|
576 client_dict_unset, |
3793 | 577 client_dict_atomic_inc |
578 } | |
579 }; |