Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4631:f5d53a684856 HEAD
SIGHUP caused memory corruption
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 25 Sep 2006 15:07:12 +0300 |
parents | 9dc62b7594de |
children | 35ecfba4ab39 |
files | src/master/login-process.c src/master/login-process.h |
diffstat | 2 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/master/login-process.c Mon Sep 25 13:30:59 2006 +0300 +++ b/src/master/login-process.c Mon Sep 25 15:07:12 2006 +0300 @@ -63,6 +63,7 @@ struct login_group *group; group = i_new(struct login_group, 1); + group->refcount = 1; group->set = set; group->process_type = set->protocol == MAIL_PROTOCOL_IMAP ? PROCESS_TYPE_IMAP : PROCESS_TYPE_POP3; @@ -71,8 +72,13 @@ login_groups = group; } -static void login_group_destroy(struct login_group *group) +static void login_group_unref(struct login_group *group) { + i_assert(group->refcount > 0); + + if (--group->refcount > 0) + return; + i_free(group); } @@ -300,6 +306,12 @@ login_process_destroy(p); return; } + { + static int i = 0; + if (i++ > 1) { + ret = -1; errno = EINVAL; + } + } if (ret != sizeof(req)) { if (ret == 0) { @@ -383,6 +395,7 @@ p->state = LOGIN_STATE_LISTENING; if (p->group != NULL) { + p->group->refcount++; p->group->processes++; p->group->listening_processes++; } @@ -425,6 +438,9 @@ if (--p->refcount > 0) return; + if (p->group != NULL) + login_group_unref(p->group); + o_stream_unref(&p->output); i_free(p); } @@ -637,7 +653,7 @@ struct login_group *group = login_groups; login_groups = group->next; - login_group_destroy(group); + login_group_unref(group); } }