dict-process.c revision 97d4906cf332727cdea5b49cbcbc7638ff600d55
bf40639e42957133fef54f2f0a322061ac37fe90nd/* Copyright (c) 2006-2009 Dovecot authors, see the included COPYING file */
bf40639e42957133fef54f2f0a322061ac37fe90ndstatic int dict_process_create(struct dict_listener *listener)
bf40639e42957133fef54f2f0a322061ac37fe90nd unsigned int i, count;
bf40639e42957133fef54f2f0a322061ac37fe90nd if (pid < 0) {
bf40639e42957133fef54f2f0a322061ac37fe90nd return -1;
bf40639e42957133fef54f2f0a322061ac37fe90nd if (pid != 0) {
bf40639e42957133fef54f2f0a322061ac37fe90nd /* master */
bf40639e42957133fef54f2f0a322061ac37fe90nd /* set stdin and stdout to /dev/null, so anything written into it
bf40639e42957133fef54f2f0a322061ac37fe90nd gets ignored. */
bf40639e42957133fef54f2f0a322061ac37fe90nd /* stderr = log, 3 = listener */
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg for (i = 0; i <= 3; i++)
0662ed52e814f8f08ef0e09956413a792584eddffuankg env_put(t_strdup_printf("DICT_%s=%s", dicts[i], dicts[i+1]));
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg /* make sure we don't leak syslog fd, but do it last so that
bf40639e42957133fef54f2f0a322061ac37fe90nd any errors above will be logged */
bf40639e42957133fef54f2f0a322061ac37fe90nd i_fatal_status(FATAL_EXEC, "execv(%s) failed: %m", executable);
bf40639e42957133fef54f2f0a322061ac37fe90nd return -1;
bf40639e42957133fef54f2f0a322061ac37fe90ndstatic void dict_process_deinit(struct dict_process *process)
bf40639e42957133fef54f2f0a322061ac37fe90nd for (p = &process->listener->processes; *p != NULL; p++) {
bf40639e42957133fef54f2f0a322061ac37fe90nd if (*p == process) {
0662ed52e814f8f08ef0e09956413a792584eddffuankgstatic void dict_listener_input(struct dict_listener *listener)
bf40639e42957133fef54f2f0a322061ac37fe90nd unsigned int i;
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg for (i = 0; i < settings_root->defaults->dict_process_count; i++) {
bf40639e42957133fef54f2f0a322061ac37fe90nd if (i > 0)
bf40639e42957133fef54f2f0a322061ac37fe90nd /* failed to create dict process, so just reject this
bf40639e42957133fef54f2f0a322061ac37fe90nd connection and try again later */
bf40639e42957133fef54f2f0a322061ac37fe90nd if (fd >= 0)
bf40639e42957133fef54f2f0a322061ac37fe90ndstatic struct dict_listener *dict_listener_init(const char *path)
bf40639e42957133fef54f2f0a322061ac37fe90ndstatic void dict_listener_deinit(struct dict_listener *listener)
bf40639e42957133fef54f2f0a322061ac37fe90ndstatic void
bf40639e42957133fef54f2f0a322061ac37fe90nd struct dict_process *process = (struct dict_process *)_process;
bf40639e42957133fef54f2f0a322061ac37fe90nd /* last listener died, create new ones */
bf40639e42957133fef54f2f0a322061ac37fe90nd const char *path;