Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16234
Modified Files:
cl5_api.c
Log Message:
Resolves: #430172
Summary: memory leaks after db "get" deadlocks, e.g. in CL5 trim
Description: Even if cursor->c_get returns non SUCCESS(==0), there is an
occasion that DBT data holds memory which is allocated in libdb. To release
the memory, put
slapi_ch_free ((void **)&key.data);
slapi_ch_free ((void **)&data.data);
just after the while loop, where we come to the point when cursor->c_get fails.
Index: cl5_api.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/cl5_api.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- cl5_api.c 14 Nov 2008 02:06:34 -0000 1.24
+++ cl5_api.c 26 Nov 2008 00:13:42 -0000 1.25
@@ -5387,6 +5387,21 @@
return CL5_SUCCESS;
}
+ /*
+ * Bug 430172 - memory leaks after db "get" deadlocks, e.g. in CL5 trim
+ * Even when db->c_get() does not return success, memory may have been
+ * allocated in the DBT. This seems to happen when DB_DBT_MALLOC was set,
+ * the data being retrieved is larger than the page size, and we got
+ * DB_LOCK_DEADLOCK. libdb allocates the memory and then finds itself
+ * deadlocked trying to go through the overflow page list. It returns
+ * DB_LOCK_DEADLOCK which we've assumed meant that no memory was allocated
+ * for the DBT.
+ *
+ * The following slapi_ch_free frees the memory only when the value is
+ * non NULL, which is true if the situation described above occurs.
+ */
+ slapi_ch_free ((void **)&key.data);
+ slapi_ch_free ((void **)&data.data);
/* walked of the end of the file */
if (rc == DB_NOTFOUND)
@@ -5456,6 +5471,21 @@
return rc;
}
+ /*
+ * Bug 430172 - memory leaks after db "get" deadlocks, e.g. in CL5 trim
+ * Even when db->c_get() does not return success, memory may have been
+ * allocated in the DBT. This seems to happen when DB_DBT_MALLOC was set,
+ * the data being retrieved is larger than the page size, and we got
+ * DB_LOCK_DEADLOCK. libdb allocates the memory and then finds itself
+ * deadlocked trying to go through the overflow page list. It returns
+ * DB_LOCK_DEADLOCK which we've assumed meant that no memory was allocated
+ * for the DBT.
+ *
+ * The following slapi_ch_free frees the memory only when the value is
+ * non NULL, which is true if the situation described above occurs.
+ */
+ slapi_ch_free ((void **)&key.data);
+ slapi_ch_free ((void **)&data.data);
/* walked of the end of the file or entry is out of range */
if (rc == 0 || rc == DB_NOTFOUND)
Show replies by date