aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2013-06-07 17:04:47 +0200
committerPatrik Nyblom <[email protected]>2013-06-07 17:04:47 +0200
commitc0c3cc2b516408b673db3202815d52c39d91451e (patch)
treefb162952ca0acaa3d5c81f662043269e60300700 /lib/crypto
parentdcbb1d2d2e07da8f3343b47eba1aeb1dfed70c7d (diff)
downloadotp-c0c3cc2b516408b673db3202815d52c39d91451e.tar.gz
otp-c0c3cc2b516408b673db3202815d52c39d91451e.tar.bz2
otp-c0c3cc2b516408b673db3202815d52c39d91451e.zip
Teach crypto.c not to call enif_compute_timeslice with 0
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/c_src/crypto.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index b07db47fd6..00abeb9990 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -143,13 +143,16 @@
}
/* This shall correspond to the similar macro in crypto.erl */
-#define MAX_BYTES_TO_NIF 20000 /* Current value is: erlang:system_info(context_reductions) * 10 */
+/* Current value is: erlang:system_info(context_reductions) * 10 */
+#define MAX_BYTES_TO_NIF 20000
#define CONSUME_REDS(NifEnv, Ibin) \
do { \
- int _cost = ((Ibin).size * 100) / MAX_BYTES_TO_NIF; \
- (void) enif_consume_timeslice((NifEnv), \
- (_cost > 100) ? 100 : _cost); \
+ int _cost = ((Ibin).size * 100) / MAX_BYTES_TO_NIF;\
+ if (_cost) { \
+ (void) enif_consume_timeslice((NifEnv), \
+ (_cost > 100) ? 100 : _cost); \
+ } \
} while (0)
/* NIF interface declarations */