Skip to content

Commit a941017

Browse files
Fix #248
1 parent 2d920a0 commit a941017

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/conn.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ int conn_create(juice_agent_t *agent, udp_socket_config_t *config) {
135135
mutex_unlock(&entry->mutex);
136136
return -1;
137137
}
138+
138139
conn_registry_t *registry = entry->registry;
139140

140141
JLOG_DEBUG("Creating connection");
@@ -301,15 +302,21 @@ int juice_mux_listen(const char *bind_address, int local_port, juice_cb_mux_inco
301302
return -1;
302303
}
303304

304-
conn_registry_t *registry = acquire_registry(entry, &config);
305-
mutex_unlock(&entry->mutex);
305+
if(acquire_registry(entry, &config)) { // locks the registry if created
306+
mutex_unlock(&entry->mutex);
307+
return -1;
308+
}
306309

307-
if (!registry)
308-
return -2;
310+
conn_registry_t *registry = entry->registry;
311+
if(!registry) {
312+
mutex_unlock(&entry->mutex);
313+
return -1;
314+
}
309315

310316
registry->cb_mux_incoming = cb;
311317
registry->mux_incoming_user_ptr = user_ptr;
312-
mutex_unlock(&registry->mutex);
313318

319+
mutex_unlock(&registry->mutex);
320+
mutex_unlock(&entry->mutex);
314321
return 0;
315322
}

0 commit comments

Comments
 (0)