Mercurial > dovecot > core-2.2
comparison src/lib-master/master-service-settings.c @ 10952:30e2d65eb67a HEAD
config: Send client a services names that have more specific settings.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 19 Mar 2010 17:23:56 +0200 |
parents | 480bf5fefcce |
children | 2d7b7fb99693 |
comparison
equal
deleted
inserted
replaced
10951:edd11ffa467c | 10952:30e2d65eb67a |
---|---|
228 } | 228 } |
229 return 0; | 229 return 0; |
230 } | 230 } |
231 | 231 |
232 static int | 232 static int |
233 config_read_reply_header(struct istream *input, const char *path, | 233 config_read_reply_header(struct istream *istream, const char *path, pool_t pool, |
234 const struct master_service_settings_input *input, | |
234 struct master_service_settings_output *output_r, | 235 struct master_service_settings_output *output_r, |
235 const char **error_r) | 236 const char **error_r) |
236 { | 237 { |
237 const char *line; | 238 const char *line; |
238 ssize_t ret; | 239 ssize_t ret; |
239 | 240 |
240 while ((ret = i_stream_read(input)) > 0) { | 241 while ((ret = i_stream_read(istream)) > 0) { |
241 line = i_stream_next_line(input); | 242 line = i_stream_next_line(istream); |
242 if (line != NULL) | 243 if (line != NULL) |
243 break; | 244 break; |
244 } | 245 } |
245 if (ret <= 0) { | 246 if (ret <= 0) { |
246 if (ret == 0) | 247 if (ret == 0) |
247 return 1; | 248 return 1; |
248 *error_r = input->stream_errno != 0 ? | 249 *error_r = istream->stream_errno != 0 ? |
249 t_strdup_printf("read(%s) failed: %m", path) : | 250 t_strdup_printf("read(%s) failed: %m", path) : |
250 t_strdup_printf("read(%s) failed: EOF", path); | 251 t_strdup_printf("read(%s) failed: EOF", path); |
251 return -1; | 252 return -1; |
252 } | 253 } |
253 | 254 |
254 T_BEGIN { | 255 T_BEGIN { |
255 const char *const *arg = t_strsplit(line, "\t"); | 256 const char *const *arg = t_strsplit(line, "\t"); |
256 | 257 ARRAY_TYPE(const_string) services; |
258 | |
259 p_array_init(&services, pool, 8); | |
257 for (; *arg != NULL; arg++) { | 260 for (; *arg != NULL; arg++) { |
258 if (strcmp(*arg, "service-uses-local") == 0) | 261 if (strcmp(*arg, "service-uses-local") == 0) |
259 output_r->service_uses_local = TRUE; | 262 output_r->service_uses_local = TRUE; |
260 else if (strcmp(*arg, "service-uses-remote") == 0) | 263 else if (strcmp(*arg, "service-uses-remote") == 0) |
261 output_r->service_uses_remote = TRUE; | 264 output_r->service_uses_remote = TRUE; |
262 if (strcmp(*arg, "used-local") == 0) | 265 if (strcmp(*arg, "used-local") == 0) |
263 output_r->used_local = TRUE; | 266 output_r->used_local = TRUE; |
264 else if (strcmp(*arg, "used-remote") == 0) | 267 else if (strcmp(*arg, "used-remote") == 0) |
265 output_r->used_remote = TRUE; | 268 output_r->used_remote = TRUE; |
269 else if (strncmp(*arg, "service=", 8) == 0) { | |
270 const char *name = p_strdup(pool, *arg + 8); | |
271 array_append(&services, &name, 1); | |
272 } | |
273 } | |
274 if (input->service == NULL) { | |
275 (void)array_append_space(&services); | |
276 output_r->specific_services = array_idx(&services, 0); | |
266 } | 277 } |
267 } T_END; | 278 } T_END; |
268 return 0; | 279 return 0; |
269 } | 280 } |
270 | 281 |
330 now = time(NULL); | 341 now = time(NULL); |
331 timeout = now + CONFIG_READ_TIMEOUT_SECS; | 342 timeout = now + CONFIG_READ_TIMEOUT_SECS; |
332 do { | 343 do { |
333 alarm(timeout - now); | 344 alarm(timeout - now); |
334 ret = config_read_reply_header(istream, path, | 345 ret = config_read_reply_header(istream, path, |
346 service->set_pool, input, | |
335 output_r, error_r); | 347 output_r, error_r); |
336 if (ret == 0) { | 348 if (ret == 0) { |
337 ret = settings_parse_stream_read(parser, | 349 ret = settings_parse_stream_read(parser, |
338 istream); | 350 istream); |
339 if (ret < 0) | 351 if (ret < 0) |