Created
June 26, 2014 18:28
-
-
Save thirtythreeforty/8b26cf6a9811fb638e55 to your computer and use it in GitHub Desktop.
Patch to icedemo.c that causes PJLIB to deadlock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pjsip-apps/src/samples/icedemo.c b/pjsip-apps/src/samples/icedemo.c | |
index 8dbba21..ed6fba9 100644 | |
--- a/pjsip-apps/src/samples/icedemo.c | |
+++ b/pjsip-apps/src/samples/icedemo.c | |
@@ -72,6 +72,8 @@ static struct app_t | |
} icedemo; | |
+pj_mutex_t *application_mutex; | |
+ | |
/* Utility to display error messages */ | |
static void icedemo_perror(const char *title, pj_status_t status) | |
{ | |
@@ -227,11 +229,12 @@ static void cb_on_rx_data(pj_ice_strans *ice_st, | |
// Don't do this! It will ruin the packet buffer in case TCP is used! | |
//((char*)pkt)[size] = '\0'; | |
- PJ_LOG(3,(THIS_FILE, "Component %d: received %d bytes data from %s: \"%.*s\"", | |
- comp_id, size, | |
- pj_sockaddr_print(src_addr, ipstr, sizeof(ipstr), 3), | |
- (unsigned)size, | |
- (char*)pkt)); | |
+ pj_mutex_lock(application_mutex); | |
+ | |
+ PJ_LOG(3,(THIS_FILE, "Data recvd")); | |
+ | |
+ pj_mutex_unlock(application_mutex); | |
+ | |
} | |
/* | |
@@ -993,13 +996,20 @@ static void icedemo_send_data(unsigned comp_id, const char *data) | |
return; | |
} | |
- status = pj_ice_strans_sendto(icedemo.icest, comp_id, data, strlen(data), | |
- &icedemo.rem.def_addr[comp_id-1], | |
- pj_sockaddr_get_len(&icedemo.rem.def_addr[comp_id-1])); | |
- if (status != PJ_SUCCESS) | |
- icedemo_perror("Error sending data", status); | |
- else | |
- PJ_LOG(3,(THIS_FILE, "Data sent")); | |
+ while(1) { | |
+ pj_mutex_lock(application_mutex); | |
+ | |
+ status = pj_ice_strans_sendto(icedemo.icest, comp_id, data, strlen(data), | |
+ &icedemo.rem.def_addr[comp_id-1], | |
+ pj_sockaddr_get_len(&icedemo.rem.def_addr[comp_id-1])); | |
+ | |
+ pj_mutex_unlock(application_mutex); | |
+ | |
+ if (status != PJ_SUCCESS) | |
+ icedemo_perror("Error sending data", status); | |
+ else | |
+ PJ_LOG(3,(THIS_FILE, "Data sent")); | |
+ } | |
} | |
@@ -1265,8 +1275,12 @@ int main(int argc, char *argv[]) | |
if (status != PJ_SUCCESS) | |
return 1; | |
+ pj_mutex_create_simple(icedemo.pool, NULL, &application_mutex); | |
+ | |
icedemo_console(); | |
+ pj_mutex_destroy(&application_mutex); | |
+ | |
err_exit("Quitting..", PJ_SUCCESS); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment