]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
yield when doing b64 encode to avoid stealing the cpu on single proc crappy hardware
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Sep 2011 21:46:10 +0000 (16:46 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Sep 2011 21:47:21 +0000 (16:47 -0500)
src/switch_utils.c

index 7d6fc21f555a7fa549f7cdf2312dd39dbe54c76d..3b9ad79c2faae10ac1026692041ba25fe5bb5b4d 100644 (file)
@@ -465,6 +465,10 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size
        for (x = 0; x < ilen; x++) {
                b = (b << 8) + in[x];
                l += 8;
+
+               if ((X % 1024) == 0) {
+                       switch_cond_next(); /* give other processes/threads a chance */
+               }
                while (l >= 6) {
                        out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64];
                        if (++y != 72) {
@@ -641,6 +645,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
                        }
 
                        while ((ilen = read(ifd, in, B64BUFFLEN))) {
+                               switch_cond_next(); /* give other processes/threads a chance */
                                for (x = 0; x < ilen; x++) {
                                        b = (b << 8) + in[x];
                                        l += 8;