summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoriko Hosoi <nhosoi@jiji.sjc.redhat.com>2010-03-21 17:13:18 -0700
committerNoriko Hosoi <nhosoi@jiji.sjc.redhat.com>2010-03-21 17:13:18 -0700
commit04a0bd9ada0b3dd8efae67b63421dfa31e15b051 (patch)
tree1781a3858df385f77a7d87859e11704429081725
parent6236bb36b7afddceb41528f31f604f8940a752f2 (diff)
downloadds-04a0bd9ada0b3dd8efae67b63421dfa31e15b051.tar.gz
ds-04a0bd9ada0b3dd8efae67b63421dfa31e15b051.tar.xz
ds-04a0bd9ada0b3dd8efae67b63421dfa31e15b051.zip
548533 - memory leak in Repl_5_Inc_Protocol_new
https://bugzilla.redhat.com/show_bug.cgi?id=548533 Description: repl5_inc_delete and repl5_tot_delete to release the incremental and total update protocol were not implemented. This fix implemented them. Also, it fixed a leak of connection in private_protocol_factory.
-rw-r--r--ldap/servers/plugins/replication/repl5_inc_protocol.c14
-rw-r--r--ldap/servers/plugins/replication/repl5_protocol.c38
-rw-r--r--ldap/servers/plugins/replication/repl5_tot_protocol.c18
3 files changed, 56 insertions, 14 deletions
diff --git a/ldap/servers/plugins/replication/repl5_inc_protocol.c b/ldap/servers/plugins/replication/repl5_inc_protocol.c
index 4e733dec..d999d3bb 100644
--- a/ldap/servers/plugins/replication/repl5_inc_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_inc_protocol.c
@@ -511,7 +511,21 @@ static void
repl5_inc_delete(Private_Repl_Protocol **prpp)
{
/* First, stop the protocol if it isn't already stopped */
+ if (!(*prpp)->stopped) {
+ (*prpp)->stopped = 1;
+ (*prpp)->stop(*prpp);
+ }
/* Then, delete all resources used by the protocol */
+ if ((*prpp)->lock) {
+ PR_DestroyLock((*prpp)->lock);
+ (*prpp)->lock = NULL;
+ }
+ if ((*prpp)->cvar) {
+ PR_DestroyCondVar((*prpp)->cvar);
+ (*prpp)->cvar = NULL;
+ }
+ slapi_ch_free((void **)&(*prpp)->private);
+ slapi_ch_free((void **)prpp);
}
/* helper function */
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c
index efb32716..31f6072b 100644
--- a/ldap/servers/plugins/replication/repl5_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_protocol.c
@@ -109,11 +109,7 @@ prot_new(Repl_Agmt *agmt, int protocol_state)
goto loser;
}
rp->agmt = agmt;
- /* now done in private_protocol_factory
- if ((rp->conn = conn_new(agmt)) == NULL)
- {
- goto loser;
- } */
+ rp->conn = NULL;
/* Acquire the local replica object */
replarea_sdn = agmt_get_replarea(agmt);
rp->replica_object = replica_get_replica_from_dn(replarea_sdn);
@@ -585,20 +581,36 @@ private_protocol_factory(Repl_Protocol *rp, int type)
switch (type)
{
case PROTOCOL_5_INCREMENTAL:
- if ((rp->conn = conn_new(rp->agmt)) != NULL)
- prp = Repl_5_Inc_Protocol_new(rp);
+ if (NULL == rp->conn) {
+ rp->conn = conn_new(rp->agmt);
+ }
+ if (NULL != rp->conn) {
+ prp = Repl_5_Inc_Protocol_new(rp);
+ }
break;
case PROTOCOL_5_TOTAL:
- if ((rp->conn = conn_new(rp->agmt)) != NULL)
- prp = Repl_5_Tot_Protocol_new(rp);
+ if (NULL == rp->conn) {
+ rp->conn = conn_new(rp->agmt);
+ }
+ if (NULL != rp->conn) {
+ prp = Repl_5_Tot_Protocol_new(rp);
+ }
break;
case PROTOCOL_WINDOWS_INCREMENTAL:
- if ((rp->conn = windows_conn_new(rp->agmt)) != NULL)
- prp = Windows_Inc_Protocol_new(rp);
+ if (NULL == rp->conn) {
+ rp->conn = windows_conn_new(rp->agmt);
+ }
+ if (NULL != rp->conn) {
+ prp = Windows_Inc_Protocol_new(rp);
+ }
break;
case PROTOCOL_WINDOWS_TOTAL:
- if ((rp->conn = windows_conn_new(rp->agmt)) != NULL)
- prp = Windows_Tot_Protocol_new(rp);
+ if (NULL == rp->conn) {
+ rp->conn = windows_conn_new(rp->agmt);
+ }
+ if (NULL != rp->conn) {
+ prp = Windows_Tot_Protocol_new(rp);
+ }
break;
}
return prp;
diff --git a/ldap/servers/plugins/replication/repl5_tot_protocol.c b/ldap/servers/plugins/replication/repl5_tot_protocol.c
index 11c82553..7bd6e258 100644
--- a/ldap/servers/plugins/replication/repl5_tot_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_tot_protocol.c
@@ -584,8 +584,24 @@ loser:
}
static void
-repl5_tot_delete(Private_Repl_Protocol **prp)
+repl5_tot_delete(Private_Repl_Protocol **prpp)
{
+ /* First, stop the protocol if it isn't already stopped */
+ if (!(*prpp)->stopped) {
+ (*prpp)->stopped = 1;
+ (*prpp)->stop(*prpp);
+ }
+ /* Then, delete all resources used by the protocol */
+ if ((*prpp)->lock) {
+ PR_DestroyLock((*prpp)->lock);
+ (*prpp)->lock = NULL;
+ }
+ if ((*prpp)->cvar) {
+ PR_DestroyCondVar((*prpp)->cvar);
+ (*prpp)->cvar = NULL;
+ }
+ slapi_ch_free((void **)&(*prpp)->private);
+ slapi_ch_free((void **)prpp);
}
static