Set LUA_MASKCOUNT hook more selectively. Fixes issue #480.
Set LUA_MASKCOUNT hook more selectively. Fixes issue #480.

An user reported a crash with Redis scripting (see issue #480 on
github), inspection of the kindly provided strack trace showed that
server.lua_caller was probably set to NULL. The stack trace also slowed
that the call to the hook was originating from a point where we just
used to set/get a few global variables in the Lua state.

What was happening is that we did not set the timeout hook selectively
only when the user script was called. Now we set it more selectively,
specifically only in the context of the lua_pcall() call, and make sure
to remove the hook when the call returns. Otherwise the hook can get
called in random contexts every time we do something with the Lua
state.

guker/redis,spinlock/redis,YongMan/redis,arijitvt/redis,gongice/redis-3.0-annotated,iandyh/redis,MSOpenTech/redis,ofirluzon/redis,GitHubMota/redis,zhaobo1023/redis-3.0-annotated,badboy/redis,zhiliaoniu/redis,AALEKH/redis,seppo0010/rlite-server,maodeyi/redis_lua,SummonY/redis,fengshao0907/redis,idning/redis,rouzier/redis,kensou97/redis,allengaller/redis,RepmujNetsik/redis,tanghaodong25/redis,LongXQ/redis,cusspvz/redis,0x20h/redis,moonbingbing/redis-3.0-annotated,taoguan/redis,ketor/redis,kmiku7/redis,CodeJuan/redis,twskipper/redis,Wangyao14cyy/redis,gilala/bjredis,seppo0010/redis,jasonkying/redis,viongpanzi/annotated_redis_source,citusdata/redis,wangyikai/redis,SyntaxStacks/redis,dongqifan2/redis-3.0-annotated,janekmi/redis,shreesundara/redis,pkdevbox/redis,cnbin/redis,aluzzardi/redis,sunlianqiang/redis-3.0-annotated,clamoriniere1A/redis,xuguruogu/redis,harrisonfeng/redis,aim-for-better/redis,ituncle/redis,AplayER/redis,jingjidejuren/redis,GitHubMota/redis,fengshao0907/redis,yuzhangjob/redis-3.0-annotated-unstable,universsky/redis,hgl888/redis,charsyam/redis,idning/redis,sunheehnus/redis,pietern/redis,badboy/redis,AplayER/redis,HouKangkang/redis-3.0-annotated,healerkx/redis,timothyohare/3rdPartySrc-redis,zhiliaoniu/redis,universsky/redis,josiahcarlson/redis,HunanTV/redis,xuzhezhaozhao/redis_reading,ton31337/redis,cnbin/redis,brg-liuwei/redis,fengshao0907/redis-3.0-annotated,zy416548283/redis-3.0-annotated,simplestbest/redis,MasahikoSawada/redis,soloestoy/redis,ofirluzon/redis,fengshao0907/annotated_redis_source,iandyh/redis,gspandy/annotated_redis_source,ipmobiletech/redis,nuxeh/redis,seandsky/redis,JoeWoo/redis,abhiklodh/redis,ituncle/redis,takeshineshiro/redis,YuanZhewei/redis,RepmujNetsik/redis,gongice/redis-3.0-annotated,GitHubMota/redis,devaos/redis,ctripcorp/redis,healerkx/redis,mpalmer/redis,wujf/redis,dongqifan2/redis-3.0-annotated,riyan8250/redis,hornen/redis,programmecat/redis,cnbin/redis,nnog/redis,louisliangjun/redis,csuhawk/redis,wuyu201321060203/redis-3.0-annotated,abhiklodh/redis,brg-liuwei/redis,miaoyc1989/redis-3.0-annotated,timothyohare/3rdPartySrc-redis,linfangrong/redis,adamweixuan/redis-3.0-annotated,fengshao0907/redis-3.0-annotated,louisliangjun/redis,aluzzardi/redis,july2993/redis,takeshineshiro/redis,josephholsten/redis,hornen/redis,4396/redis,netroby/redis,thomasdarimont/redis,buobao/redis-3.0-annotated,Hailei/redis,mverrilli/redis,ChaosCoo/annotated_redis_source,saisai/redis,seppo0010/redis,valdsJohn/redis,ytjiang/redis,allengaller/redis,miaoyc1989/redis-3.0-annotated,zhcy/redis,shining-yang/redis,YuanZhewei/redis,magastzheng/redis-3.0-annotated,narma/redis,timothyohare/3rdPartySrc-redis,Cisphyx/redis-websockets,atreeyang/redis,Aliceljm1/redis,yuzhangjob/redis-3.0-annotated-unstable,alenslan/redis,xujunhai1991/redis,j0hnma/hszredis,ChanningDuan/annotated_redis_source,charsyam/redis,neomantra/redis,StevenTsai/redis,dreamquster/redis,neomantra/redis,ipmobiletech/redis,saisai/redis,190235047/redis,AplayER/redis,h0x91b/redis,thomasdarimont/redis,riyan8250/redis,allengaller/redis,pedigree/redis,mengyou0304/redis,AplayER/redis,dreamquster/redis,ytjiang/redis,GrimDerp/redis,zhoudayang/redis,josephholsten/redis,thomasdarimont/redis,neomantra/redis,pedigree/redis,rouzier/redis,citusdata/redis,idning/redis,onlymellb/redis-3.0-annotated,tjschuck/redis,nilyang/redis-tdd-annotation,4396/redis,shining-yang/redis,pkdevbox/redis,hedisdb/hedis,csuhawk/redis,hawkchch/redis,YuanZhewei/redis,slfs007/mk-redis,mingyaaaa/redis,0x55/redis-3.0-annotated,dayuoba/redis,harrisonfeng/redis,jasonkying/redis,ituncle/redis,shreesundara/redis,miaoyc1989/redis-3.0-annotated,JoeWoo/redis,shining-yang/redis,qiyang0221/redis,spearhead-ea/redis,tellapart/redis,OmarQunsul/graph-redis,whille/redis-3.0-annotated,tjschuck/redis,HunanTV/redis,supasate/redis,oranagra/redis,kmiku7/redis,figoxu/annotated_redis_source,HeartSaVioR/redis,ofirluzon/redis,PKRoma/redis,OmarQunsul/graph-redis,onlymellb/redis-3.0-annotated,zhiliaoniu/redis,holstvoogd/redis,ctripcorp/redis,supasate/redis,zhaobo1023/redis-3.0-annotated,blackmady/redis,ouyangkongtong/redis,izhoujie/redis,wenxueliu/redis_comment,fengshao0907/redis,kmiku7/redis,0x20h/redis,zczhuohuo/redis,zhcy/redis,tidatida/annotated_redis_source,WorkingOfTimtohyZhang/redis-3.0-annotated,nnog/redis,huyuezheng/redis,dreamquster/redis,MSOpenTech/redis,Aaron1992/redis,Instagram/redis,Cisphyx/redis-websockets,gilala/hredis,SyntaxStacks/redis,idning/redis,simplestbest/redis,danny200309/annotated_redis_source,yossigo/redis,j0hnma/hszredis,0x55/redis-3.0-annotated,badboy/redis,mumingv/redis,guker/redis,unasm/redis-3.0-annotated,Aliceljm1/redis,wuyu201321060203/redis-3.0-annotated,supasate/redis,davidradunz/redis,WorkingOfTimtohyZhang/redis-3.0-annotated,linfangrong/redis,JoeWoo/redis,xlzhan/redis,ErikDubbelboer/redis,huangz1990/annotated_redis_source,honestme/redis,j0hnma/szredis,tjschuck/redis,itamarhaber/redis,Markgorden/redis,hhli/redis,takeshineshiro/redis,z-fork/redis,spinlock/redis,mgk/redis,190235047/redis,MSOpenTech/redis,YongMan/redis,mengyou0304/redis,itugs/redis,MSOpenTech/redis,cloudrain21/redis,hedisdb/hedis,izhoujie/redis,OmarQunsul/graph-redis,YongMan/redis,jermnelson/redis,duanx/redis,MasahikoSawada/redis,a-pavlov/redis,nuxeh/redis,ksarch-saas/redis,colstrom/redis,GrimDerp/redis,weizijun/redis,kensou97/redis,ketor/redis,soveran/redis,h0x91b/redis,Aliceljm1/redis,drinkthere/redis-3.0-annotated,qiyang0221/redis,rouzier/redis,moonbingbing/redis-3.0-annotated,mengzhejin/RedisStudy,LongXQ/redis,alenslan/redis,spearhead-ea/redis,darksideofthemoo/redis-histogram,dayuoba/redis,jbochi/redis,francischan714/redis,soloestoy/redis,vincent-vivian-liu/redis,louisliangjun/redis,netroby/redis,ksarch-saas/redis,mumingv/redis,csuhawk/redis,hhli/redis,jbochi/parallel_redis,simplestbest/redis,PKRoma/redis,josephholsten/redis,h0x91b/redis,july2993/redis,shshlzh/redis-3.0-annotated,holstvoogd/redis,mengyou0304/redis,spinlock/redis,ton31337/redis,twskipper/redis,clamoriniere1A/redis,roth1002/redis,haima-zju/redis-3.0-annotated,slfs007/mk-redis,timothyohare/3rdPartySrc-redis,wprice/redis,huangz1990/redis-3.0-annotated,adamweixuan/redis-3.0-annotated,harrisonfeng/redis,splitice/redis,narma/redis,shshlzh/redis-3.0-annotated,RepmujNetsik/redis,davidradunz/redis,rogerlz/redis,pietern/redis,NBSW/redis,ReadCode/redis-3.0-annotated,zy416548283/redis-3.0-annotated,july2993/redis,xuzhezhaozhao/redis_reading,jingjidejuren/redis,LongXQ/redis,holstvoogd/redis,janekmi/redis,oranagra/redis,0x55/redis-3.0-annotated,shreesundara/redis,jxwr/redis,netroby/redis,zhiliaoniu/redis,devaos/redis,PKRoma/redis,PKRoma/redis,huangz1990/experiment-redis,yybirdcf/learn-redis,huyuezheng/redis,huangz1990/experiment-redis,zhcy/redis,vincent-vivian-liu/redis,badboy/redis,cloudrain21/redis,yybirdcf/learn-redis,flashbuckets/redis,jackyan/redis,darksideofthemoo/redis-histogram,gspandy/annotated_redis_source,fengshao0907/redis-3.0-annotated,valdsJohn/redis,oranagra/redis,ErikDubbelboer/redis,wbailey5/redis,ytjiang/redis,ncopa/redis,Soledad89/redis,aluzzardi/redis,dramenk/annotated_redis_source,msn217/redis-3.0-annotated,roth1002/redis,j0hnma/szredis,gaoxianglong/redis,PradheepShrinivasan/redis,taoguan/redis,ChaosCoo/annotated_redis_source,SummonY/redis,ton31337/redis,a-pavlov/redis,janekmi/redis,cusspvz/redis,ChanningDuan/annotated_redis_source,mverrilli/redis,antirez/redis,fankeke/redis-3.0-annotated,riyan8250/redis,ipmobiletech/redis,elkingtonmcb/redis,jackyan/redis,splitice/redis,jacklee0810/redis-3.0-annotated,xujunhai1991/redis,ctripcorp/redis,HunanTV/redis,fankeke/redis-3.0-annotated,wuxiaowei907/annotated_redis_source,Sciumo/redis,machicao2013/redis-source-annotated,zguangyu/redis,pmem/redis,wujf/redis,Sciumo/redis,twskipper/redis,jbochi/redis,taoguan/redis,rogerchina/redis,kmiku7/redis,wangyikai/redis,sunheehnus/redis,yossigo/redis,ituncle/redis,weizijun/redis,huangz1990/experiment-redis,brg-liuwei/redis,seandsky/redis,mrb/redis,sunlianqiang/redis-3.0-annotated,mcanthony/redis,machicao2013/redis-source-annotated,hawkchch/redis,mumingv/redis-3.0-annotated,itugs/redis,rogerchina/redis,hgl888/redis,tjschuck/redis,raphaelfruneaux/redis,mgk/redis,wbailey5/redis,healerkx/redis,rogerlz/redis,0x20h/redis,zhoudayang/redis,ipmobiletech/redis,brg-liuwei/redis,soveran/redis,abhiklodh/redis,Aliceljm1/redis-3.0-annotated,ouyangkongtong/redis,OmarQunsul/graph-redis,mengzhejin/RedisStudy,mrb/redis,thomasdarimont/redis,slfs007/mk-redis,huangz1990/annotated_redis_source,cnbin/redis,ketor/redis,xuguruogu/redis,jingjidejuren/redis,gilala/hbjredis,blackmady/redis,guker/redis,guker/redis,Aaron1992/redis,MOON-CLJ/redis,ttuna/msot-redis,YuraLukashik/redis,dreamquster/redis,cloudrain21/redis,drinkthere/redis-3.0-annotated,HeartSaVioR/redis,YongMan/redis,zhcy/redis,AALEKH/redis,himoca/redis,jxwr/redis,ncopa/redis,arijitvt/redis,190235047/redis,zhoudayang/redis,shreesundara/redis,cusspvz/redis,mengyou0304/redis,hhli/redis,josiahcarlson/redis,honestme/redis,zguangyu/redis,shshlzh/redis-3.0-annotated,colstrom/redis,unasm/redis-3.0-annotated,jacklee0810/redis-3.0-annotated,aim-for-better/redis,pcarrier/redis,huangz1990/redis-3.0-annotated,0x55/redis-3.0-annotated,j0hnma/hszredis,xlzhan/redis,hawkchch/redis,NBSW/redis,kaushik94/redis,ouyangkongtong/redis,Aliceljm1/redis-3.0-annotated,programmecat/redis,hgl888/redis,jbochi/parallel_redis,SummonY/redis,wuxiaowei907/annotated_redis_source,nilyang/redis-tdd-annotation,itugs/redis,mumingv/redis-3.0-annotated,allengaller/redis,gaoxianglong/redis,tzq668766/redis-3.0-annotated,gilala/hredis,RepmujNetsik/redis,zy416548283/redis-3.0-annotated,aim-for-better/redis,GrimDerp/redis,CodeJuan/redis,mpalmer/redis,ChanningDuan/annotated_redis_source,takeshineshiro/redis,xuzhezhaozhao/redis_reading,mverrilli/redis,gilala/hbjredis,gaoxianglong/redis,maodeyi/redis_lua,atreeyang/redis,itamarhaber/redis,mumingv/redis,roth1002/redis,gilala/redis,StevenTsai/redis,arijitvt/redis,SyntaxStacks/redis,maodeyi/redis_lua,jbochi/redis,gechong/redis-3.0-annotated,oranagra/redis,rogerlz/redis,devaos/redis,MOON-CLJ/redis,clamoriniere1A/redis,wujf/redis,gechong/redis-3.0-annotated,kaushik94/redis,harrisonfeng/redis,pkdevbox/redis,honestme/redis,raphaelfruneaux/redis,ttuna/msot-redis,programmecat/redis,clamoriniere1A/redis,dongqifan2/redis-3.0-annotated,honestme/redis,Sciumo/redis,roth1002/redis,PradheepShrinivasan/redis,msn217/redis-3.0-annotated,zczhuohuo/redis,charsyam/redis,oranagra/redis,modulexcite/redis,flashbuckets/redis,zczhuohuo/redis,miaoyc1989/redis-3.0-annotated,whille/redis-3.0-annotated,yossigo/redis,buobao/redis-3.0-annotated,hedisdb/hedis,machicao2013/redis-source-annotated,gilala/bjredis,ttuna/msot-redis,mrb/redis,ttuna/msot-redis,tellapart/redis,z-fork/redis,magastzheng/redis-3.0-annotated,saisai/redis,mpalmer/redis,z-fork/redis,HouKangkang/redis-3.0-annotated,zhoudayang/redis,spearhead-ea/redis,dayuoba/redis,GrimDerp/redis,AALEKH/redis,tanghaodong25/redis,splitice/redis,nilyang/redis-tdd-annotation,LongXQ/redis,HeartSaVioR/redis,NBSW/redis,wuyu201321060203/redis-3.0-annotated,mumingv/redis,Wangyao14cyy/redis,tidatida/annotated_redis_source,wbailey5/redis,blackmady/redis,citusdata/redis,HeartSaVioR/redis,kaushik94/redis,cloudrain21/redis,wprice/redis,fengshao0907/annotated_redis_source,taoguan/redis,qiyang0221/redis,shshlzh/redis-3.0-annotated,mumingv/redis-3.0-annotated,saisai/redis,xuguruogu/redis,Hailei/redis,CodeJuan/redis,wbailey5/redis,gilala/hredis,Aaron1992/redis,jasonkying/redis,citusdata/redis,HunanTV/redis,mattsta/redis,gspandy/annotated_redis_source,elkingtonmcb/redis,haima-zju/redis-3.0-annotated,spinlock/redis,soloestoy/redis,xujunhai1991/redis,blackmady/redis,viongpanzi/annotated_redis_source,duanx/redis,seandsky/redis,wuxiaowei907/annotated_redis_source,soveran/redis,tidatida/annotated_redis_source,pietern/redis,PradheepShrinivasan/redis,abhiklodh/redis,tellapart/redis,zguangyu/redis,StevenTsai/redis,josiahcarlson/redis,mingyaaaa/redis,rogerchina/redis,machicao2013/redis-source-annotated,danny200309/annotated_redis_source,ramonsnir/redis,tanghaodong25/redis,MSOpenTech/redis,j0hnma/szredis,antirez/redis,WorkingOfTimtohyZhang/redis-3.0-annotated,huangz1990/annotated_redis_source,danny200309/annotated_redis_source,AALEKH/redis,ChaosCoo/annotated_redis_source,mcanthony/redis,j0hnma/hszredis,simplestbest/redis,huangz1990/redis-3.0-annotated,pietern/redis,huangz1990/experiment-redis,jingjidejuren/redis,rouzier/redis,modulexcite/redis,pedigree/redis,tellapart/redis,louisliangjun/redis,atreeyang/redis,seandsky/redis,duanx/redis,Soledad89/redis,drinkthere/redis-3.0-annotated,Markgorden/redis,ramonsnir/redis,itamarhaber/redis,fengshao0907/redis,SyntaxStacks/redis,seppo0010/rlite-server,mverrilli/redis,Cisphyx/redis-websockets,atreeyang/redis,rrsean/redis-3.0-annotated,soloestoy/redis,flashbuckets/redis,zguangyu/redis,splitice/redis,a-pavlov/redis,mingyaaaa/redis,davidradunz/redis,xujunhai1991/redis,gilala/bjredis,alenslan/redis,charsyam/redis,francischan714/redis,programmecat/redis,sunheehnus/redis,h0x91b/redis,mrb/redis,j0hnma/szredis,dayuoba/redis,colstrom/redis,pedigree/redis,StevenTsai/redis,francischan714/redis,pcarrier/redis,figoxu/annotated_redis_source,alenslan/redis,antirez/redis,4396/redis,jxwr/redis,nnog/redis,gechong/redis-3.0-annotated,ReadCode/redis-3.0-annotated,yuhc/redis-benchmark-enhanced,GitHubMota/redis,sunheehnus/redis,Instagram/redis,yuhc/redis-benchmark-enhanced,rogerlz/redis,zczhuohuo/redis,francischan714/redis,universsky/redis,vincent-vivian-liu/redis,colstrom/redis,onlymellb/redis-3.0-annotated,gilala/redis,kensou97/redis,jackyan/redis,mgk/redis,jackyan/redis,Cisphyx/redis-websockets,HouKangkang/redis-3.0-annotated,ton31337/redis,jacklee0810/redis-3.0-annotated,xuguruogu/redis,hgl888/redis,mcanthony/redis,josiahcarlson/redis,wprice/redis,YuraLukashik/redis,mcanthony/redis,yossigo/redis,magastzheng/redis-3.0-annotated,PradheepShrinivasan/redis,tzq668766/redis-3.0-annotated,seppo0010/rlite-server,universsky/redis,iandyh/redis,hedisdb/hedis,huyuezheng/redis,Aliceljm1/redis-3.0-annotated,jasonkying/redis,aim-for-better/redis,z-fork/redis,narma/redis,hornen/redis,itugs/redis,weizijun/redis,mattsta/redis,ctripcorp/redis,elkingtonmcb/redis,Markgorden/redis,gilala/redis,figoxu/annotated_redis_source,moonbingbing/redis-3.0-annotated,ramonsnir/redis,csuhawk/redis,supasate/redis,jermnelson/redis,gilala/redis,healerkx/redis,CodeJuan/redis,ksarch-saas/redis,Sciumo/redis,flashbuckets/redis,MOON-CLJ/redis,holstvoogd/redis,wangyikai/redis,kaushik94/redis,xlzhan/redis,modulexcite/redis,jacklee0810/annotated_redis_source,nuxeh/redis,arijitvt/redis,YuanZhewei/redis,viongpanzi/annotated_redis_source,ncopa/redis,a-pavlov/redis,yossigo/redis,MasahikoSawada/redis,fankeke/redis-3.0-annotated,wangyikai/redis,hhli/redis,Hailei/redis,izhoujie/redis,ytjiang/redis,yybirdcf/learn-redis,yuzhangjob/redis-3.0-annotated-unstable,wuyu201321060203/redis-3.0-annotated,Wangyao14cyy/redis,unasm/redis-3.0-annotated,gilala/hbjredis,zhaobo1023/redis-3.0-annotated,mingyaaaa/redis,gaoxianglong/redis,wujf/redis,pmem/redis,himoca/redis,msn217/redis-3.0-annotated,tanghaodong25/redis,Wangyao14cyy/redis,Soledad89/redis,wenxueliu/redis_comment,darksideofthemoo/redis-histogram,yuhc/redis-benchmark-enhanced,pcarrier/redis,cusspvz/redis,iandyh/redis,wprice/redis,antirez/redis,himoca/redis,MasahikoSawada/redis,Hailei/redis,mpalmer/redis,rogerchina/redis,itamarhaber/redis,hornen/redis,rrsean/redis-3.0-annotated,nilyang/redis-tdd-annotation,whille/redis-3.0-annotated,NBSW/redis,izhoujie/redis,linfangrong/redis,tzq668766/redis-3.0-annotated,kensou97/redis,vincent-vivian-liu/redis,Aliceljm1/redis,netroby/redis,yybirdcf/learn-redis,nnog/redis,wenxueliu/redis_comment,gilala/hredis,elkingtonmcb/redis,JoeWoo/redis,pmem/redis,raphaelfruneaux/redis,twskipper/redis,YuraLukashik/redis,ofirluzon/redis,aluzzardi/redis,wenxueliu/redis_comment,xlzhan/redis,janekmi/redis,rrsean/redis-3.0-annotated,modulexcite/redis,PKRoma/redis,neomantra/redis,190235047/redis,shining-yang/redis,0x20h/redis,qiyang0221/redis,adamweixuan/redis-3.0-annotated,jbochi/parallel_redis,Aaron1992/redis,Soledad89/redis,gilala/hbjredis,dramenk/annotated_redis_source,SummonY/redis,Markgorden/redis,dramenk/annotated_redis_source,nuxeh/redis,ErikDubbelboer/redis,weizijun/redis,charsyam/redis,riyan8250/redis,xuzhezhaozhao/redis_reading,ncopa/redis,sunlianqiang/redis-3.0-annotated,soveran/redis,pcarrier/redis,ouyangkongtong/redis,soloestoy/redis,Instagram/redis,gongice/redis-3.0-annotated,mgk/redis,huyuezheng/redis,fengshao0907/annotated_redis_source,gilala/bjredis,mattsta/redis,ReadCode/redis-3.0-annotated,jacklee0810/annotated_redis_source,YuraLukashik/redis,neomantra/redis,4396/redis,hawkchch/redis,duanx/redis,seppo0010/redis,mengzhejin/RedisStudy,haima-zju/redis-3.0-annotated,seppo0010/rlite-server,yuhc/redis-benchmark-enhanced,ErikDubbelboer/redis,mengzhejin/RedisStudy,valdsJohn/redis,jacklee0810/annotated_redis_source,valdsJohn/redis,pkdevbox/redis,ttuna/msot-redis,ofirluzon/redis,jermnelson/redis,buobao/redis-3.0-annotated,darksideofthemoo/redis-histogram,july2993/redis,linfangrong/redis,davidradunz/redis,pmem/redis,devaos/redis,seppo0010/redis,ksarch-saas/redis