Skip to content

Commit

Permalink
Fix #248
Browse files Browse the repository at this point in the history
  • Loading branch information
paullouisageneau committed Jan 9, 2025
1 parent 2d920a0 commit a941017
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ int conn_create(juice_agent_t *agent, udp_socket_config_t *config) {
mutex_unlock(&entry->mutex);
return -1;
}

conn_registry_t *registry = entry->registry;

JLOG_DEBUG("Creating connection");
Expand Down Expand Up @@ -301,15 +302,21 @@ int juice_mux_listen(const char *bind_address, int local_port, juice_cb_mux_inco
return -1;
}

conn_registry_t *registry = acquire_registry(entry, &config);
mutex_unlock(&entry->mutex);
if(acquire_registry(entry, &config)) { // locks the registry if created
mutex_unlock(&entry->mutex);
return -1;
}

if (!registry)
return -2;
conn_registry_t *registry = entry->registry;
if(!registry) {
mutex_unlock(&entry->mutex);
return -1;
}

registry->cb_mux_incoming = cb;
registry->mux_incoming_user_ptr = user_ptr;
mutex_unlock(&registry->mutex);

mutex_unlock(&registry->mutex);
mutex_unlock(&entry->mutex);
return 0;
}

0 comments on commit a941017

Please sign in to comment.