This commit is contained in:
Anthony Minessale 2012-01-26 16:54:27 -06:00
parent 049be82ae8
commit 812e5e9a26
5 changed files with 47 additions and 51 deletions

View File

@ -3425,7 +3425,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_p
status = create_file(session, profile, record_macro, file_path, &message_len, SWITCH_TRUE, key_buf, buf); status = create_file(session, profile, record_macro, file_path, &message_len, SWITCH_TRUE, key_buf, buf);
if ((status == SWITCH_STATUS_NOTFOUND)) { if (status == SWITCH_STATUS_NOTFOUND) {
goto end; goto end;
} }

View File

@ -3132,7 +3132,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
} }
} }
if ((sub_state == nua_substate_active)) { if (sub_state == nua_substate_active) {
sstr = switch_mprintf("active;expires=%ld", exp_delta); sstr = switch_mprintf("active;expires=%ld", exp_delta);

View File

@ -2037,7 +2037,7 @@ void sofia_reg_handle_sip_r_challenge(int status,
if (!var_gateway && realm) { if (!var_gateway && realm) {
char rb[512] = ""; char rb[512] = "";
char *p = (char *) realm; char *p = (char *) realm;
while ((*p == '"')) { while (*p == '"') {
p++; p++;
} }
switch_set_string(rb, p); switch_set_string(rb, p);

View File

@ -183,60 +183,61 @@ static JSBool socket_read_bytes(JSContext * cx, JSObject * obj, uintN argc, jsva
static JSBool socket_read(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval) static JSBool socket_read(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
{ {
js_socket_obj_t *socket = JS_GetPrivate(cx, obj); js_socket_obj_t *socket = JS_GetPrivate(cx, obj);
char *delimiter = "\n";
switch_status_t ret = SWITCH_STATUS_FALSE;
switch_size_t len = 1;
switch_size_t total_length = 0;
int can_run = TRUE;
char tempbuf[2];
if (socket == NULL) { if (socket == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find js object.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find js object.\n");
return JS_FALSE; return JS_FALSE;
} }
if (argc >= 0) { if (argc == 1) {
char *delimiter = "\n"; delimiter = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
switch_status_t ret = SWITCH_STATUS_FALSE; }
switch_size_t len = 1;
switch_size_t total_length = 0;
int can_run = TRUE;
char tempbuf[2];
if (argc == 1) if (socket->read_buffer == 0) {
delimiter = JS_GetStringBytes(JS_ValueToString(cx, argv[0])); socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
}
socket->saveDepth = JS_SuspendRequest(cx);
if (socket->read_buffer == 0) while (can_run == TRUE) {
socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size); ret = switch_socket_recv(socket->socket, tempbuf, &len);
if (ret != SWITCH_STATUS_SUCCESS)
break;
socket->saveDepth = JS_SuspendRequest(cx); tempbuf[1] = 0;
while (can_run == TRUE) { if (tempbuf[0] == delimiter[0])
ret = switch_socket_recv(socket->socket, tempbuf, &len); break;
if (ret != SWITCH_STATUS_SUCCESS) else if (tempbuf[0] == '\r' && delimiter[0] == '\n')
break; continue;
else {
tempbuf[1] = 0; // Buffer is full, let's increase it.
if (tempbuf[0] == delimiter[0]) if (total_length == socket->buffer_size - 1) {
break; switch_size_t new_size = socket->buffer_size + 4196;
else if (tempbuf[0] == '\r' && delimiter[0] == '\n') char *new_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
continue; memcpy(new_buffer, socket->read_buffer, total_length);
else { socket->buffer_size = new_size;
// Buffer is full, let's increase it. socket->read_buffer = new_buffer;
if (total_length == socket->buffer_size - 1) {
switch_size_t new_size = socket->buffer_size + 4196;
char *new_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
memcpy(new_buffer, socket->read_buffer, total_length);
socket->buffer_size = new_size;
socket->read_buffer = new_buffer;
}
socket->read_buffer[total_length] = tempbuf[0];
++total_length;
} }
} socket->read_buffer[total_length] = tempbuf[0];
JS_ResumeRequest(cx, socket->saveDepth); ++total_length;
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "socket receive failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
} else {
socket->read_buffer[total_length] = 0;
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, socket->read_buffer));
} }
} }
JS_ResumeRequest(cx, socket->saveDepth);
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "socket receive failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
} else {
socket->read_buffer[total_length] = 0;
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, socket->read_buffer));
}
return JS_TRUE; return JS_TRUE;
} }

View File

@ -3029,7 +3029,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
#ifdef ENABLE_ZRTP #ifdef ENABLE_ZRTP
/* ZRTP Send */ /* ZRTP Send */
if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) { if (zrtp_on && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
unsigned int sbytes = (int) bytes; unsigned int sbytes = (unsigned int) bytes;
zrtp_status_t stat = zrtp_status_fail; zrtp_status_t stat = zrtp_status_fail;
stat = zrtp_process_rtcp(other_rtp_session->zrtp_stream, (void *) &other_rtp_session->rtcp_send_msg, &sbytes); stat = zrtp_process_rtcp(other_rtp_session->zrtp_stream, (void *) &other_rtp_session->rtcp_send_msg, &sbytes);
@ -3067,11 +3067,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
} }
} }
if (bytes < 0) {
ret = (int) bytes;
goto end;
}
if (bytes && rtp_session->recv_msg.header.version == 2 && if (bytes && rtp_session->recv_msg.header.version == 2 &&
!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) &&