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);
if ((status == SWITCH_STATUS_NOTFOUND)) {
if (status == SWITCH_STATUS_NOTFOUND) {
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);

View File

@ -2037,7 +2037,7 @@ void sofia_reg_handle_sip_r_challenge(int status,
if (!var_gateway && realm) {
char rb[512] = "";
char *p = (char *) realm;
while ((*p == '"')) {
while (*p == '"') {
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)
{
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) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to find js object.\n");
return JS_FALSE;
}
if (argc >= 0) {
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 (argc == 1) {
delimiter = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
}
if (argc == 1)
delimiter = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
if (socket->read_buffer == 0) {
socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
}
socket->saveDepth = JS_SuspendRequest(cx);
if (socket->read_buffer == 0)
socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
while (can_run == TRUE) {
ret = switch_socket_recv(socket->socket, tempbuf, &len);
if (ret != SWITCH_STATUS_SUCCESS)
break;
socket->saveDepth = JS_SuspendRequest(cx);
while (can_run == TRUE) {
ret = switch_socket_recv(socket->socket, tempbuf, &len);
if (ret != SWITCH_STATUS_SUCCESS)
break;
tempbuf[1] = 0;
if (tempbuf[0] == delimiter[0])
break;
else if (tempbuf[0] == '\r' && delimiter[0] == '\n')
continue;
else {
// Buffer is full, let's increase it.
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;
tempbuf[1] = 0;
if (tempbuf[0] == delimiter[0])
break;
else if (tempbuf[0] == '\r' && delimiter[0] == '\n')
continue;
else {
// Buffer is full, let's increase it.
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;
}
}
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));
socket->read_buffer[total_length] = tempbuf[0];
++total_length;
}
}
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;
}

View File

@ -3029,7 +3029,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
#ifdef ENABLE_ZRTP
/* ZRTP Send */
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;
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 &&
!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_UDPTL) &&