summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/changes.xml6
-rw-r--r--src/nxt_unit.c20
2 files changed, 14 insertions, 12 deletions
diff --git a/docs/changes.xml b/docs/changes.xml
index 989001dd..0175fd33 100644
--- a/docs/changes.xml
+++ b/docs/changes.xml
@@ -122,6 +122,12 @@ the prototype crashed.
</para>
</change>
+<change type="bugfix">
+<para>
+mutex leak in the C API.
+</para>
+</change>
+
</changes>
diff --git a/src/nxt_unit.c b/src/nxt_unit.c
index fd086b2c..e5cb0b58 100644
--- a/src/nxt_unit.c
+++ b/src/nxt_unit.c
@@ -585,9 +585,14 @@ fail:
static nxt_unit_impl_t *
nxt_unit_create(nxt_unit_init_t *init)
{
- int rc;
- nxt_unit_impl_t *lib;
- nxt_unit_callbacks_t *cb;
+ int rc;
+ nxt_unit_impl_t *lib;
+
+ if (nxt_slow_path(init->callbacks.request_handler == NULL)) {
+ nxt_unit_alert(NULL, "request_handler is NULL");
+
+ return NULL;
+ }
lib = nxt_unit_malloc(NULL,
sizeof(nxt_unit_impl_t) + init->request_data_size);
@@ -630,15 +635,6 @@ nxt_unit_create(nxt_unit_init_t *init)
goto fail;
}
- cb = &lib->callbacks;
-
- if (cb->request_handler == NULL) {
- nxt_unit_alert(NULL, "request_handler is NULL");
-
- pthread_mutex_destroy(&lib->mutex);
- goto fail;
- }
-
nxt_unit_mmaps_init(&lib->incoming);
nxt_unit_mmaps_init(&lib->outgoing);