Skip to content

Commit

Permalink
disable multithreading for very small files
Browse files Browse the repository at this point in the history
  • Loading branch information
gurnec committed Jul 26, 2016
1 parent 5363770 commit f046b97
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
6 changes: 3 additions & 3 deletions installer/HashCheck.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ FunctionEnd
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Catalan"

VIProductVersion "2.3.2.11"
VIProductVersion "2.3.2.12"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "HashCheck Shell Extension"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.2.11"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "2.3.2.12"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer distributed from https://github.com/gurnec/HashCheck/releases"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" ""
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright © Kai Liu, Christopher Gurnee, Tim Schlueter. All rights reserved."
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Installer (x86/x64) from https://github.com/gurnec/HashCheck/releases"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.2.11"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "2.3.2.12"

; With solid compression, files that are required before the
; actual installation should be stored first in the data block,
Expand Down
62 changes: 34 additions & 28 deletions libs/WinHash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,46 +134,52 @@ VOID WHAPI WHInitEx( PWHCTXEX pContext )
VOID WHAPI WHUpdateEx( PWHCTXEX pContext, PCBYTE pbIn, UINT cbIn )
{
#if _MSC_VER >= 1600
auto task_WHUpdateSHA512 = concurrency::make_task([&] { WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); } );
auto task_WHUpdateSHA256 = concurrency::make_task([&] { WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn); } );
auto task_WHUpdateSHA1 = concurrency::make_task([&] { WHUpdateSHA1 (&pContext->ctxSHA1, pbIn, cbIn); } );
auto task_WHUpdateMD5 = concurrency::make_task([&] { WHUpdateMD5 (&pContext->ctxMD5, pbIn, cbIn); } );
auto task_WHUpdateCRC32 = concurrency::make_task([&] { WHUpdateCRC32 (&pContext->ctxCRC32, pbIn, cbIn); } );
if (cbIn > 384u) { // determined experimentally--smaller than this and multithreading doesn't help, but ymmv

concurrency::structured_task_group hashing_task_group;
auto task_WHUpdateSHA512 = concurrency::make_task([&] { WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn); } );
auto task_WHUpdateSHA256 = concurrency::make_task([&] { WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn); } );
auto task_WHUpdateSHA1 = concurrency::make_task([&] { WHUpdateSHA1 (&pContext->ctxSHA1, pbIn, cbIn); } );
auto task_WHUpdateMD5 = concurrency::make_task([&] { WHUpdateMD5 (&pContext->ctxMD5, pbIn, cbIn); } );
auto task_WHUpdateCRC32 = concurrency::make_task([&] { WHUpdateCRC32 (&pContext->ctxCRC32, pbIn, cbIn); } );

if (pContext->flags & WHEX_CHECKSHA512)
hashing_task_group.run(task_WHUpdateSHA512);
concurrency::structured_task_group hashing_task_group;

if (pContext->flags & WHEX_CHECKSHA256)
hashing_task_group.run(task_WHUpdateSHA256);
if (pContext->flags & WHEX_CHECKSHA512)
hashing_task_group.run(task_WHUpdateSHA512);

if (pContext->flags & WHEX_CHECKSHA1)
hashing_task_group.run(task_WHUpdateSHA1);
if (pContext->flags & WHEX_CHECKSHA256)
hashing_task_group.run(task_WHUpdateSHA256);

if (pContext->flags & WHEX_CHECKMD5)
hashing_task_group.run(task_WHUpdateMD5);
if (pContext->flags & WHEX_CHECKSHA1)
hashing_task_group.run(task_WHUpdateSHA1);

if (pContext->flags & WHEX_CHECKCRC32)
hashing_task_group.run(task_WHUpdateCRC32);
if (pContext->flags & WHEX_CHECKMD5)
hashing_task_group.run(task_WHUpdateMD5);

hashing_task_group.wait();
if (pContext->flags & WHEX_CHECKCRC32)
hashing_task_group.run(task_WHUpdateCRC32);

#else
if (pContext->flags & WHEX_CHECKCRC32)
WHUpdateCRC32(&pContext->ctxCRC32, pbIn, cbIn);
hashing_task_group.wait();
}

if (pContext->flags & WHEX_CHECKMD5)
WHUpdateMD5(&pContext->ctxMD5, pbIn, cbIn);
else {
#endif
if (pContext->flags & WHEX_CHECKCRC32)
WHUpdateCRC32(&pContext->ctxCRC32, pbIn, cbIn);

if (pContext->flags & WHEX_CHECKSHA1)
WHUpdateSHA1(&pContext->ctxSHA1, pbIn, cbIn);
if (pContext->flags & WHEX_CHECKMD5)
WHUpdateMD5(&pContext->ctxMD5, pbIn, cbIn);

if (pContext->flags & WHEX_CHECKSHA256)
WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn);
if (pContext->flags & WHEX_CHECKSHA1)
WHUpdateSHA1(&pContext->ctxSHA1, pbIn, cbIn);

if (pContext->flags & WHEX_CHECKSHA512)
WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn);
if (pContext->flags & WHEX_CHECKSHA256)
WHUpdateSHA256(&pContext->ctxSHA256, pbIn, cbIn);

if (pContext->flags & WHEX_CHECKSHA512)
WHUpdateSHA512(&pContext->ctxSHA512, pbIn, cbIn);
#if _MSC_VER >= 1600
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
HashCheck Shell Extension

Copyright (C) 2008-2009 Kai Liu. All rights reserved.
Copyright (C) 2014 Christopher Gurnee. All rights reserved.
Copyright (C) 2014, 2016 Christopher Gurnee. All rights reserved.
Copyright (C) 2014 Software Development Laboratories ("Fish" (David B. Trout))
Copyright (C) 2016 Tim Schlueter. All rights reserved.

Expand Down
4 changes: 2 additions & 2 deletions version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#define HASHCHECK_NAME_STR "HashCheck Shell Extension"

// Full version: MUST be in the form of major,minor,revision,build
#define HASHCHECK_VERSION_FULL 2,3,2,11
#define HASHCHECK_VERSION_FULL 2,3,2,12

// String version: May be any suitable string
#define HASHCHECK_VERSION_STR "2.3.2.11"
#define HASHCHECK_VERSION_STR "2.3.2.12"

#ifdef _USRDLL
// PE version: MUST be in the form of major.minor
Expand Down

0 comments on commit f046b97

Please sign in to comment.