aboutsummaryrefslogtreecommitdiffstats
path: root/apps/speed.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2010-01-17 17:31:38 +0000
committerAndy Polyakov <appro@openssl.org>2010-01-17 17:31:38 +0000
commitd582c98d8f3b1c953a990305ba00201c8c122a55 (patch)
tree394aed3282c6ec47f5b826178c750a3712dec726 /apps/speed.c
parent78a533cb93ca7f235ad594a619fdb715f3a78ce6 (diff)
downloadopenssl-d582c98d8f3b1c953a990305ba00201c8c122a55.tar.gz
apps/speed.c: limit loop counters to 2^31 in order to avoid overflows
in performance calculations. For the moment there is only one code fast enough to suffer from this: Intel AES-NI engine. PR: 2096
Diffstat (limited to 'apps/speed.c')
-rw-r--r--apps/speed.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/apps/speed.c b/apps/speed.c
index cf5b8b7001..67a816743e 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -277,9 +277,11 @@ static DWORD WINAPI sleepy(VOID *arg)
static double Time_F(int s)
{
+ double ret;
+ static HANDLE thr;
+
if (s == START)
{
- HANDLE thr;
schlock = 0;
thr = CreateThread(NULL,4096,sleepy,NULL,0,NULL);
if (thr==NULL)
@@ -288,17 +290,25 @@ static double Time_F(int s)
BIO_printf(bio_err,"unable to CreateThread (%d)",ret);
ExitProcess(ret);
}
- CloseHandle(thr); /* detach the thread */
while (!schlock) Sleep(0); /* scheduler spinlock */
+ ret = app_tminterval(s,usertime);
+ }
+ else
+ {
+ ret = app_tminterval(s,usertime);
+ if (run) TerminateThread(thr,0);
+ CloseHandle(thr);
}
- return app_tminterval(s,usertime);
+ return ret;
}
#else
static double Time_F(int s)
{
- return app_tminterval(s,usertime);
+ double ret = app_tminterval(s,usertime);
+ if (s == STOP) alarm(0);
+ return ret;
}
#endif
@@ -1454,7 +1464,7 @@ int MAIN(int argc, char **argv)
# error "You cannot disable DES on systems without SIGALRM."
#endif /* OPENSSL_NO_DES */
#else
-#define COND(c) (run)
+#define COND(c) (run && count<0x7fffffff)
#define COUNT(d) (count)
#ifndef _WIN32
signal(SIGALRM,sig_done);