]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-2216
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 26 Jan 2012 22:54:27 +0000 (16:54 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 26 Jan 2012 22:54:27 +0000 (16:54 -0600)
src/mod/applications/mod_voicemail/mod_voicemail.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c
src/mod/languages/mod_spidermonkey/mod_spidermonkey_socket.c
src/switch_rtp.c

index 53007a3abcc5dcc05b86fe2e58958c0ede27a33c..d8fbee8e6bf92a238212bdc78687546f685e504c 100644 (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;
        }
 
index 280ce6f9862b00effb429286477f4212eaa18035..3d3674b82e38913319ab3b37bec3cdb085b66857 100644 (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);
                
index 14fbfcad7b79e8795aab4b973d973add6b83ab89..3c86824a333323baa96ca2a2ff0094c03da1346e 100644 (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);
index 3a57b4ee2e6ce8eefc1c80116a313c30b7a20f01..c76744fc8d5f0e38cf78f1899b3b1c1deea59459 100644 (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);
+       }
 
-               if (socket->read_buffer == 0)
-                       socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
+       socket->saveDepth = JS_SuspendRequest(cx);
 
-               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;
+       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;
                }
-               JS_ResumeRequest(cx, socket->saveDepth);
+       }
+       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));
-               }
+       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;
 }
index 7d61fc9eabb27c4d094f64e15ce041faf773dc07..5c966cde6e4ee269433cfb75d6c70e5af4a1952c 100644 (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) &&