Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/master/login-process.c @ 4670:5372b92be174 HEAD
Reference counter fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 14 Oct 2006 02:50:09 +0300 |
parents | 654aa0e9075b |
children | f032a5d2bc0d |
comparison
equal
deleted
inserted
replaced
4669:d84a7bd63862 | 4670:5372b92be174 |
---|---|
437 | 437 |
438 i_assert(pid != 0); | 438 i_assert(pid != 0); |
439 | 439 |
440 p = i_new(struct login_process, 1); | 440 p = i_new(struct login_process, 1); |
441 p->group = group; | 441 p->group = group; |
442 p->refcount = 1; | 442 p->refcount = 2; /* once for fd close, another for process exit */ |
443 p->pid = pid; | 443 p->pid = pid; |
444 p->fd = fd; | 444 p->fd = fd; |
445 p->io = io_add(fd, IO_READ, login_process_input, p); | 445 p->io = io_add(fd, IO_READ, login_process_input, p); |
446 p->output = o_stream_create_file(fd, default_pool, | 446 p->output = o_stream_create_file(fd, default_pool, |
447 sizeof(struct master_login_reply)*10, | 447 sizeof(struct master_login_reply)*10, |
485 | 485 |
486 process_mark_nonlistening(p, LOGIN_STATE_FULL_LOGINS); | 486 process_mark_nonlistening(p, LOGIN_STATE_FULL_LOGINS); |
487 | 487 |
488 if (p->inetd_child) | 488 if (p->inetd_child) |
489 login_process_exited(p); | 489 login_process_exited(p); |
490 login_process_unref(p); | |
490 } | 491 } |
491 | 492 |
492 static void login_process_unref(struct login_process *p) | 493 static void login_process_unref(struct login_process *p) |
493 { | 494 { |
495 i_assert(p->refcount > 0); | |
494 if (--p->refcount > 0) | 496 if (--p->refcount > 0) |
495 return; | 497 return; |
496 | 498 |
497 if (p->group != NULL) | 499 if (p->group != NULL) |
498 login_group_unref(p->group); | 500 login_group_unref(p->group); |
687 the time */ | 689 the time */ |
688 if (p->group != NULL) | 690 if (p->group != NULL) |
689 p->group->wanted_processes_count = 0; | 691 p->group->wanted_processes_count = 0; |
690 } | 692 } |
691 | 693 |
692 login_process_destroy(p); | |
693 login_process_exited(p); | 694 login_process_exited(p); |
694 } | 695 } |
695 | 696 |
696 void login_processes_destroy_all(bool unref) | 697 void login_processes_destroy_all(void) |
697 { | 698 { |
698 struct hash_iterate_context *iter; | 699 struct hash_iterate_context *iter; |
699 void *key, *value; | 700 void *key, *value; |
700 | 701 |
701 iter = hash_iterate_init(processes); | 702 iter = hash_iterate_init(processes); |
702 while (hash_iterate(iter, &key, &value)) { | 703 while (hash_iterate(iter, &key, &value)) |
703 login_process_destroy(value); | 704 login_process_destroy(value); |
704 if (unref) login_process_unref(value); | |
705 } | |
706 hash_iterate_deinit(iter); | 705 hash_iterate_deinit(iter); |
707 | 706 |
708 while (login_groups != NULL) { | 707 while (login_groups != NULL) { |
709 struct login_group *group = login_groups; | 708 struct login_group *group = login_groups; |
710 | 709 |
891 } | 890 } |
892 } | 891 } |
893 | 892 |
894 void login_processes_deinit(void) | 893 void login_processes_deinit(void) |
895 { | 894 { |
896 login_processes_destroy_all(TRUE); | 895 login_processes_destroy_all(); |
897 hash_destroy(processes); | 896 hash_destroy(processes); |
898 | 897 |
899 if (to != NULL) | 898 if (to != NULL) |
900 timeout_remove(&to); | 899 timeout_remove(&to); |
901 if (io_listen != NULL) | 900 if (io_listen != NULL) |