]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/tpool.c
Merge remote-tracking branch 'origin/mdb.RE/0.9' into OPENLDAP_REL_ENG_2_4
[openldap] / libraries / libldap_r / tpool.c
index 87e959449134e27655421229d308455db581e0b8..cb95e7df49c78c7a08667919b2ae0fa8c06374ce 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2013 The OpenLDAP Foundation.
+ * Copyright 1998-2015 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -214,14 +214,22 @@ ldap_pvt_thread_pool_init (
        if (pool == NULL) return(-1);
 
        rc = ldap_pvt_thread_mutex_init(&pool->ltp_mutex);
-       if (rc != 0)
+       if (rc != 0) {
+fail1:
+               LDAP_FREE(pool);
                return(rc);
+       }
        rc = ldap_pvt_thread_cond_init(&pool->ltp_cond);
-       if (rc != 0)
-               return(rc);
+       if (rc != 0) {
+fail2:
+               ldap_pvt_thread_mutex_destroy(&pool->ltp_mutex);
+               goto fail1;
+       }
        rc = ldap_pvt_thread_cond_init(&pool->ltp_pcond);
-       if (rc != 0)
-               return(rc);
+       if (rc != 0) {
+               ldap_pvt_thread_cond_destroy(&pool->ltp_cond);
+               goto fail2;
+       }
 
        ldap_int_has_thread_pool = 1;