├── .gitignore ├── Chapter01 └── codes │ ├── .DS_Store │ ├── TestRAII1 │ ├── ReadMe.txt │ ├── TestRAII1.cpp │ ├── TestRAII1.sln │ ├── TestRAII1.vcxproj │ ├── TestRAII1.vcxproj.filters │ ├── TestRAII2.cpp │ ├── TestRAII3.cpp │ ├── TestRAII4.cpp │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── construct_complex_objects.cpp │ ├── test_auto_ptr.cpp │ ├── test_custom_foreach_loop.cpp │ ├── test_initializer_list.cpp │ ├── test_map_insert_or_assign.cpp │ ├── test_map_try_emplace.cpp │ ├── test_map_try_emplace_with_directobject.cpp │ ├── test_map_try_emplace_with_smartpointer.cpp │ ├── test_map_try_emplace_with_smartpointer2.cpp │ ├── test_shared_ptr_use_count.cpp │ ├── test_std_enable_shared_from_this.cpp │ ├── test_std_enable_shared_from_this_problem.cpp │ ├── test_unique_ptr.cpp │ ├── test_unique_ptr_deletor.cpp │ ├── test_unique_ptr_with_array.cpp │ └── test_weak_ptr.cpp ├── Chapter02 ├── .DS_Store ├── VisualGDB 下载与安装.md ├── cgdb下载与安装.md ├── codes │ └── main.cpp └── redis-6.0.3 │ ├── .github │ └── workflows │ │ ├── ci.yml │ │ └── daily.yml │ ├── .gitignore │ ├── 00-RELEASENOTES │ ├── BUGS │ ├── CONTRIBUTING │ ├── COPYING │ ├── INSTALL │ ├── MANIFESTO │ ├── Makefile │ ├── README.md │ ├── TLS.md │ ├── deps │ ├── Makefile │ ├── README.md │ ├── hiredis │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── CMakeLists.txt │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ ├── adapters │ │ │ ├── ae.h │ │ │ ├── glib.h │ │ │ ├── ivykis.h │ │ │ ├── libev.h │ │ │ ├── libevent.h │ │ │ ├── libuv.h │ │ │ ├── macosx.h │ │ │ └── qt.h │ │ ├── appveyor.yml │ │ ├── async.c │ │ ├── async.h │ │ ├── async_private.h │ │ ├── dict.c │ │ ├── dict.h │ │ ├── examples │ │ │ ├── CMakeLists.txt │ │ │ ├── example-ae.c │ │ │ ├── example-glib.c │ │ │ ├── example-ivykis.c │ │ │ ├── example-libev.c │ │ │ ├── example-libevent-ssl.c │ │ │ ├── example-libevent.c │ │ │ ├── example-libuv.c │ │ │ ├── example-macosx.c │ │ │ ├── example-qt.cpp │ │ │ ├── example-qt.h │ │ │ ├── example-ssl.c │ │ │ └── example.c │ │ ├── fmacros.h │ │ ├── hiredis.c │ │ ├── hiredis.h │ │ ├── hiredis.pc.in │ │ ├── hiredis_ssl.h │ │ ├── hiredis_ssl.pc.in │ │ ├── net.c │ │ ├── net.h │ │ ├── read.c │ │ ├── read.h │ │ ├── sds.c │ │ ├── sds.h │ │ ├── sdsalloc.h │ │ ├── sockcompat.c │ │ ├── sockcompat.h │ │ ├── ssl.c │ │ ├── test.c │ │ ├── test.sh │ │ └── win32.h │ ├── jemalloc │ │ ├── .appveyor.yml │ │ ├── .autom4te.cfg │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── COPYING │ │ ├── ChangeLog │ │ ├── INSTALL.md │ │ ├── Makefile.in │ │ ├── README │ │ ├── TUNING.md │ │ ├── autogen.sh │ │ ├── bin │ │ │ ├── jemalloc-config.in │ │ │ ├── jemalloc.sh.in │ │ │ └── jeprof.in │ │ ├── build-aux │ │ │ ├── config.guess │ │ │ ├── config.sub │ │ │ └── install-sh │ │ ├── config.stamp.in │ │ ├── configure.ac │ │ ├── doc │ │ │ ├── html.xsl.in │ │ │ ├── jemalloc.xml.in │ │ │ ├── manpages.xsl.in │ │ │ └── stylesheet.xsl │ │ ├── include │ │ │ ├── jemalloc │ │ │ │ ├── internal │ │ │ │ │ ├── arena_externs.h │ │ │ │ │ ├── arena_inlines_a.h │ │ │ │ │ ├── arena_inlines_b.h │ │ │ │ │ ├── arena_stats.h │ │ │ │ │ ├── arena_structs_a.h │ │ │ │ │ ├── arena_structs_b.h │ │ │ │ │ ├── arena_types.h │ │ │ │ │ ├── assert.h │ │ │ │ │ ├── atomic.h │ │ │ │ │ ├── atomic_c11.h │ │ │ │ │ ├── atomic_gcc_atomic.h │ │ │ │ │ ├── atomic_gcc_sync.h │ │ │ │ │ ├── atomic_msvc.h │ │ │ │ │ ├── background_thread_externs.h │ │ │ │ │ ├── background_thread_inlines.h │ │ │ │ │ ├── background_thread_structs.h │ │ │ │ │ ├── base_externs.h │ │ │ │ │ ├── base_inlines.h │ │ │ │ │ ├── base_structs.h │ │ │ │ │ ├── base_types.h │ │ │ │ │ ├── bin.h │ │ │ │ │ ├── bin_stats.h │ │ │ │ │ ├── bit_util.h │ │ │ │ │ ├── bitmap.h │ │ │ │ │ ├── cache_bin.h │ │ │ │ │ ├── ckh.h │ │ │ │ │ ├── ctl.h │ │ │ │ │ ├── div.h │ │ │ │ │ ├── emitter.h │ │ │ │ │ ├── extent_dss.h │ │ │ │ │ ├── extent_externs.h │ │ │ │ │ ├── extent_inlines.h │ │ │ │ │ ├── extent_mmap.h │ │ │ │ │ ├── extent_structs.h │ │ │ │ │ ├── extent_types.h │ │ │ │ │ ├── hash.h │ │ │ │ │ ├── hooks.h │ │ │ │ │ ├── jemalloc_internal_decls.h │ │ │ │ │ ├── jemalloc_internal_defs.h.in │ │ │ │ │ ├── jemalloc_internal_externs.h │ │ │ │ │ ├── jemalloc_internal_includes.h │ │ │ │ │ ├── jemalloc_internal_inlines_a.h │ │ │ │ │ ├── jemalloc_internal_inlines_b.h │ │ │ │ │ ├── jemalloc_internal_inlines_c.h │ │ │ │ │ ├── jemalloc_internal_macros.h │ │ │ │ │ ├── jemalloc_internal_types.h │ │ │ │ │ ├── jemalloc_preamble.h.in │ │ │ │ │ ├── large_externs.h │ │ │ │ │ ├── log.h │ │ │ │ │ ├── malloc_io.h │ │ │ │ │ ├── mutex.h │ │ │ │ │ ├── mutex_pool.h │ │ │ │ │ ├── mutex_prof.h │ │ │ │ │ ├── nstime.h │ │ │ │ │ ├── pages.h │ │ │ │ │ ├── ph.h │ │ │ │ │ ├── private_namespace.sh │ │ │ │ │ ├── private_symbols.sh │ │ │ │ │ ├── prng.h │ │ │ │ │ ├── prof_externs.h │ │ │ │ │ ├── prof_inlines_a.h │ │ │ │ │ ├── prof_inlines_b.h │ │ │ │ │ ├── prof_structs.h │ │ │ │ │ ├── prof_types.h │ │ │ │ │ ├── public_namespace.sh │ │ │ │ │ ├── public_unnamespace.sh │ │ │ │ │ ├── ql.h │ │ │ │ │ ├── qr.h │ │ │ │ │ ├── rb.h │ │ │ │ │ ├── rtree.h │ │ │ │ │ ├── rtree_tsd.h │ │ │ │ │ ├── size_classes.sh │ │ │ │ │ ├── smoothstep.h │ │ │ │ │ ├── smoothstep.sh │ │ │ │ │ ├── spin.h │ │ │ │ │ ├── stats.h │ │ │ │ │ ├── sz.h │ │ │ │ │ ├── tcache_externs.h │ │ │ │ │ ├── tcache_inlines.h │ │ │ │ │ ├── tcache_structs.h │ │ │ │ │ ├── tcache_types.h │ │ │ │ │ ├── ticker.h │ │ │ │ │ ├── tsd.h │ │ │ │ │ ├── tsd_generic.h │ │ │ │ │ ├── tsd_malloc_thread_cleanup.h │ │ │ │ │ ├── tsd_tls.h │ │ │ │ │ ├── tsd_types.h │ │ │ │ │ ├── tsd_win.h │ │ │ │ │ ├── util.h │ │ │ │ │ └── witness.h │ │ │ │ ├── jemalloc.sh │ │ │ │ ├── jemalloc_defs.h.in │ │ │ │ ├── jemalloc_macros.h.in │ │ │ │ ├── jemalloc_mangle.sh │ │ │ │ ├── jemalloc_protos.h.in │ │ │ │ ├── jemalloc_rename.sh │ │ │ │ └── jemalloc_typedefs.h.in │ │ │ └── msvc_compat │ │ │ │ ├── C99 │ │ │ │ ├── stdbool.h │ │ │ │ └── stdint.h │ │ │ │ ├── strings.h │ │ │ │ └── windows_extra.h │ │ ├── jemalloc.pc.in │ │ ├── m4 │ │ │ └── ax_cxx_compile_stdcxx.m4 │ │ ├── msvc │ │ │ ├── ReadMe.txt │ │ │ ├── jemalloc_vc2015.sln │ │ │ ├── jemalloc_vc2017.sln │ │ │ ├── projects │ │ │ │ ├── vc2015 │ │ │ │ │ ├── jemalloc │ │ │ │ │ │ ├── jemalloc.vcxproj │ │ │ │ │ │ └── jemalloc.vcxproj.filters │ │ │ │ │ └── test_threads │ │ │ │ │ │ ├── test_threads.vcxproj │ │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ │ └── vc2017 │ │ │ │ │ ├── jemalloc │ │ │ │ │ ├── jemalloc.vcxproj │ │ │ │ │ └── jemalloc.vcxproj.filters │ │ │ │ │ └── test_threads │ │ │ │ │ ├── test_threads.vcxproj │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ └── test_threads │ │ │ │ ├── test_threads.cpp │ │ │ │ ├── test_threads.h │ │ │ │ └── test_threads_main.cpp │ │ ├── run_tests.sh │ │ ├── scripts │ │ │ ├── gen_run_tests.py │ │ │ └── gen_travis.py │ │ ├── src │ │ │ ├── arena.c │ │ │ ├── background_thread.c │ │ │ ├── base.c │ │ │ ├── bin.c │ │ │ ├── bitmap.c │ │ │ ├── ckh.c │ │ │ ├── ctl.c │ │ │ ├── div.c │ │ │ ├── extent.c │ │ │ ├── extent_dss.c │ │ │ ├── extent_mmap.c │ │ │ ├── hash.c │ │ │ ├── hooks.c │ │ │ ├── jemalloc.c │ │ │ ├── jemalloc_cpp.cpp │ │ │ ├── large.c │ │ │ ├── log.c │ │ │ ├── malloc_io.c │ │ │ ├── mutex.c │ │ │ ├── mutex_pool.c │ │ │ ├── nstime.c │ │ │ ├── pages.c │ │ │ ├── prng.c │ │ │ ├── prof.c │ │ │ ├── rtree.c │ │ │ ├── stats.c │ │ │ ├── sz.c │ │ │ ├── tcache.c │ │ │ ├── ticker.c │ │ │ ├── tsd.c │ │ │ ├── witness.c │ │ │ └── zone.c │ │ └── test │ │ │ ├── include │ │ │ └── test │ │ │ │ ├── SFMT-alti.h │ │ │ │ ├── SFMT-params.h │ │ │ │ ├── SFMT-params11213.h │ │ │ │ ├── SFMT-params1279.h │ │ │ │ ├── SFMT-params132049.h │ │ │ │ ├── SFMT-params19937.h │ │ │ │ ├── SFMT-params216091.h │ │ │ │ ├── SFMT-params2281.h │ │ │ │ ├── SFMT-params4253.h │ │ │ │ ├── SFMT-params44497.h │ │ │ │ ├── SFMT-params607.h │ │ │ │ ├── SFMT-params86243.h │ │ │ │ ├── SFMT-sse2.h │ │ │ │ ├── SFMT.h │ │ │ │ ├── btalloc.h │ │ │ │ ├── extent_hooks.h │ │ │ │ ├── jemalloc_test.h.in │ │ │ │ ├── jemalloc_test_defs.h.in │ │ │ │ ├── math.h │ │ │ │ ├── mq.h │ │ │ │ ├── mtx.h │ │ │ │ ├── test.h │ │ │ │ ├── thd.h │ │ │ │ └── timer.h │ │ │ ├── integration │ │ │ ├── MALLOCX_ARENA.c │ │ │ ├── aligned_alloc.c │ │ │ ├── allocated.c │ │ │ ├── extent.c │ │ │ ├── extent.sh │ │ │ ├── mallocx.c │ │ │ ├── mallocx.sh │ │ │ ├── overflow.c │ │ │ ├── posix_memalign.c │ │ │ ├── rallocx.c │ │ │ ├── sdallocx.c │ │ │ ├── thread_arena.c │ │ │ ├── thread_tcache_enabled.c │ │ │ ├── xallocx.c │ │ │ └── xallocx.sh │ │ │ ├── src │ │ │ ├── SFMT.c │ │ │ ├── btalloc.c │ │ │ ├── btalloc_0.c │ │ │ ├── btalloc_1.c │ │ │ ├── math.c │ │ │ ├── mq.c │ │ │ ├── mtx.c │ │ │ ├── test.c │ │ │ ├── thd.c │ │ │ └── timer.c │ │ │ ├── stress │ │ │ └── microbench.c │ │ │ ├── test.sh.in │ │ │ └── unit │ │ │ ├── SFMT.c │ │ │ ├── a0.c │ │ │ ├── arena_reset.c │ │ │ ├── arena_reset_prof.c │ │ │ ├── arena_reset_prof.sh │ │ │ ├── atomic.c │ │ │ ├── background_thread.c │ │ │ ├── background_thread_enable.c │ │ │ ├── base.c │ │ │ ├── bit_util.c │ │ │ ├── bitmap.c │ │ │ ├── ckh.c │ │ │ ├── decay.c │ │ │ ├── decay.sh │ │ │ ├── div.c │ │ │ ├── emitter.c │ │ │ ├── extent_quantize.c │ │ │ ├── fork.c │ │ │ ├── hash.c │ │ │ ├── hooks.c │ │ │ ├── junk.c │ │ │ ├── junk.sh │ │ │ ├── junk_alloc.c │ │ │ ├── junk_alloc.sh │ │ │ ├── junk_free.c │ │ │ ├── junk_free.sh │ │ │ ├── log.c │ │ │ ├── mallctl.c │ │ │ ├── malloc_io.c │ │ │ ├── math.c │ │ │ ├── mq.c │ │ │ ├── mtx.c │ │ │ ├── nstime.c │ │ │ ├── pack.c │ │ │ ├── pack.sh │ │ │ ├── pages.c │ │ │ ├── ph.c │ │ │ ├── prng.c │ │ │ ├── prof_accum.c │ │ │ ├── prof_accum.sh │ │ │ ├── prof_active.c │ │ │ ├── prof_active.sh │ │ │ ├── prof_gdump.c │ │ │ ├── prof_gdump.sh │ │ │ ├── prof_idump.c │ │ │ ├── prof_idump.sh │ │ │ ├── prof_reset.c │ │ │ ├── prof_reset.sh │ │ │ ├── prof_tctx.c │ │ │ ├── prof_tctx.sh │ │ │ ├── prof_thread_name.c │ │ │ ├── prof_thread_name.sh │ │ │ ├── ql.c │ │ │ ├── qr.c │ │ │ ├── rb.c │ │ │ ├── retained.c │ │ │ ├── rtree.c │ │ │ ├── size_classes.c │ │ │ ├── slab.c │ │ │ ├── smoothstep.c │ │ │ ├── spin.c │ │ │ ├── stats.c │ │ │ ├── stats_print.c │ │ │ ├── ticker.c │ │ │ ├── tsd.c │ │ │ ├── witness.c │ │ │ ├── zero.c │ │ │ └── zero.sh │ ├── linenoise │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.markdown │ │ ├── example.c │ │ ├── linenoise.c │ │ └── linenoise.h │ ├── lua │ │ ├── COPYRIGHT │ │ ├── HISTORY │ │ ├── INSTALL │ │ ├── Makefile │ │ ├── README │ │ ├── doc │ │ │ ├── contents.html │ │ │ ├── cover.png │ │ │ ├── logo.gif │ │ │ ├── lua.1 │ │ │ ├── lua.css │ │ │ ├── lua.html │ │ │ ├── luac.1 │ │ │ ├── luac.html │ │ │ ├── manual.css │ │ │ ├── manual.html │ │ │ └── readme.html │ │ ├── etc │ │ │ ├── Makefile │ │ │ ├── README │ │ │ ├── all.c │ │ │ ├── lua.hpp │ │ │ ├── lua.ico │ │ │ ├── lua.pc │ │ │ ├── luavs.bat │ │ │ ├── min.c │ │ │ ├── noparser.c │ │ │ └── strict.lua │ │ ├── src │ │ │ ├── Makefile │ │ │ ├── fpconv.c │ │ │ ├── fpconv.h │ │ │ ├── lapi.c │ │ │ ├── lapi.h │ │ │ ├── lauxlib.c │ │ │ ├── lauxlib.h │ │ │ ├── lbaselib.c │ │ │ ├── lcode.c │ │ │ ├── lcode.h │ │ │ ├── ldblib.c │ │ │ ├── ldebug.c │ │ │ ├── ldebug.h │ │ │ ├── ldo.c │ │ │ ├── ldo.h │ │ │ ├── ldump.c │ │ │ ├── lfunc.c │ │ │ ├── lfunc.h │ │ │ ├── lgc.c │ │ │ ├── lgc.h │ │ │ ├── linit.c │ │ │ ├── liolib.c │ │ │ ├── llex.c │ │ │ ├── llex.h │ │ │ ├── llimits.h │ │ │ ├── lmathlib.c │ │ │ ├── lmem.c │ │ │ ├── lmem.h │ │ │ ├── loadlib.c │ │ │ ├── lobject.c │ │ │ ├── lobject.h │ │ │ ├── lopcodes.c │ │ │ ├── lopcodes.h │ │ │ ├── loslib.c │ │ │ ├── lparser.c │ │ │ ├── lparser.h │ │ │ ├── lstate.c │ │ │ ├── lstate.h │ │ │ ├── lstring.c │ │ │ ├── lstring.h │ │ │ ├── lstrlib.c │ │ │ ├── ltable.c │ │ │ ├── ltable.h │ │ │ ├── ltablib.c │ │ │ ├── ltm.c │ │ │ ├── ltm.h │ │ │ ├── lua.c │ │ │ ├── lua.h │ │ │ ├── lua_bit.c │ │ │ ├── lua_cjson.c │ │ │ ├── lua_cmsgpack.c │ │ │ ├── lua_struct.c │ │ │ ├── luac.c │ │ │ ├── luaconf.h │ │ │ ├── lualib.h │ │ │ ├── lundump.c │ │ │ ├── lundump.h │ │ │ ├── lvm.c │ │ │ ├── lvm.h │ │ │ ├── lzio.c │ │ │ ├── lzio.h │ │ │ ├── print.c │ │ │ ├── strbuf.c │ │ │ └── strbuf.h │ │ └── test │ │ │ ├── README │ │ │ ├── bisect.lua │ │ │ ├── cf.lua │ │ │ ├── echo.lua │ │ │ ├── env.lua │ │ │ ├── factorial.lua │ │ │ ├── fib.lua │ │ │ ├── fibfor.lua │ │ │ ├── globals.lua │ │ │ ├── hello.lua │ │ │ ├── life.lua │ │ │ ├── luac.lua │ │ │ ├── printf.lua │ │ │ ├── readonly.lua │ │ │ ├── sieve.lua │ │ │ ├── sort.lua │ │ │ ├── table.lua │ │ │ ├── trace-calls.lua │ │ │ ├── trace-globals.lua │ │ │ └── xd.lua │ └── update-jemalloc.sh │ ├── redis.conf │ ├── runtest │ ├── runtest-cluster │ ├── runtest-moduleapi │ ├── runtest-sentinel │ ├── sentinel.conf │ ├── src │ ├── .gitignore │ ├── Makefile │ ├── acl.c │ ├── adlist.c │ ├── adlist.h │ ├── ae.c │ ├── ae.h │ ├── ae_epoll.c │ ├── ae_evport.c │ ├── ae_kqueue.c │ ├── ae_select.c │ ├── anet.c │ ├── anet.h │ ├── aof.c │ ├── asciilogo.h │ ├── atomicvar.h │ ├── bio.c │ ├── bio.h │ ├── bitops.c │ ├── blocked.c │ ├── childinfo.c │ ├── cluster.c │ ├── cluster.h │ ├── config.c │ ├── config.h │ ├── connection.c │ ├── connection.h │ ├── connhelpers.h │ ├── crc16.c │ ├── crc16_slottable.h │ ├── crc64.c │ ├── crc64.h │ ├── crcspeed.c │ ├── crcspeed.h │ ├── db.c │ ├── debug.c │ ├── debugmacro.h │ ├── defrag.c │ ├── dict.c │ ├── dict.h │ ├── endianconv.c │ ├── endianconv.h │ ├── evict.c │ ├── expire.c │ ├── fmacros.h │ ├── geo.c │ ├── geo.h │ ├── geohash.c │ ├── geohash.h │ ├── geohash_helper.c │ ├── geohash_helper.h │ ├── gopher.c │ ├── help.h │ ├── hyperloglog.c │ ├── intset.c │ ├── intset.h │ ├── latency.c │ ├── latency.h │ ├── lazyfree.c │ ├── listpack.c │ ├── listpack.h │ ├── listpack_malloc.h │ ├── localtime.c │ ├── lolwut.c │ ├── lolwut.h │ ├── lolwut5.c │ ├── lolwut6.c │ ├── lzf.h │ ├── lzfP.h │ ├── lzf_c.c │ ├── lzf_d.c │ ├── memtest.c │ ├── mkreleasehdr.sh │ ├── module.c │ ├── modules │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── gendoc.rb │ │ ├── helloacl.c │ │ ├── helloblock.c │ │ ├── hellocluster.c │ │ ├── hellodict.c │ │ ├── hellohook.c │ │ ├── hellotimer.c │ │ ├── hellotype.c │ │ ├── helloworld.c │ │ └── testmodule.c │ ├── multi.c │ ├── networking.c │ ├── notify.c │ ├── object.c │ ├── pqsort.c │ ├── pqsort.h │ ├── pubsub.c │ ├── quicklist.c │ ├── quicklist.h │ ├── rand.c │ ├── rand.h │ ├── rax.c │ ├── rax.h │ ├── rax_malloc.h │ ├── rdb.c │ ├── rdb.h │ ├── redis-benchmark.c │ ├── redis-check-aof.c │ ├── redis-check-rdb.c │ ├── redis-cli.c │ ├── redis-trib.rb │ ├── redisassert.h │ ├── redismodule.h │ ├── release.c │ ├── replication.c │ ├── rio.c │ ├── rio.h │ ├── scripting.c │ ├── sds.c │ ├── sds.h │ ├── sdsalloc.h │ ├── sentinel.c │ ├── server.c │ ├── server.h │ ├── setcpuaffinity.c │ ├── setproctitle.c │ ├── sha1.c │ ├── sha1.h │ ├── sha256.c │ ├── sha256.h │ ├── siphash.c │ ├── slowlog.c │ ├── slowlog.h │ ├── solarisfixes.h │ ├── sort.c │ ├── sparkline.c │ ├── sparkline.h │ ├── stream.h │ ├── syncio.c │ ├── t_hash.c │ ├── t_list.c │ ├── t_set.c │ ├── t_stream.c │ ├── t_string.c │ ├── t_zset.c │ ├── testhelp.h │ ├── timeout.c │ ├── tls.c │ ├── tracking.c │ ├── util.c │ ├── util.h │ ├── valgrind.sup │ ├── version.h │ ├── ziplist.c │ ├── ziplist.h │ ├── zipmap.c │ ├── zipmap.h │ ├── zmalloc.c │ └── zmalloc.h │ ├── tests │ ├── assets │ │ ├── default.conf │ │ ├── encodings.rdb │ │ └── hash-zipmap.rdb │ ├── cluster │ │ ├── cluster.tcl │ │ ├── run.tcl │ │ ├── tests │ │ │ ├── 00-base.tcl │ │ │ ├── 01-faildet.tcl │ │ │ ├── 02-failover.tcl │ │ │ ├── 03-failover-loop.tcl │ │ │ ├── 04-resharding.tcl │ │ │ ├── 05-slave-selection.tcl │ │ │ ├── 06-slave-stop-cond.tcl │ │ │ ├── 07-replica-migration.tcl │ │ │ ├── 08-update-msg.tcl │ │ │ ├── 09-pubsub.tcl │ │ │ ├── 10-manual-failover.tcl │ │ │ ├── 11-manual-takeover.tcl │ │ │ ├── 12-replica-migration-2.tcl │ │ │ ├── 13-no-failover-option.tcl │ │ │ ├── 14-consistency-check.tcl │ │ │ ├── 15-cluster-slots.tcl │ │ │ ├── helpers │ │ │ │ └── onlydots.tcl │ │ │ └── includes │ │ │ │ └── init-tests.tcl │ │ └── tmp │ │ │ └── .gitignore │ ├── helpers │ │ ├── bg_block_op.tcl │ │ ├── bg_complex_data.tcl │ │ └── gen_write_load.tcl │ ├── instances.tcl │ ├── integration │ │ ├── aof-race.tcl │ │ ├── aof.tcl │ │ ├── block-repl.tcl │ │ ├── convert-zipmap-hash-on-load.tcl │ │ ├── logging.tcl │ │ ├── psync2-pingoff.tcl │ │ ├── psync2-reg.tcl │ │ ├── psync2.tcl │ │ ├── rdb.tcl │ │ ├── redis-cli.tcl │ │ ├── replication-2.tcl │ │ ├── replication-3.tcl │ │ ├── replication-4.tcl │ │ ├── replication-psync.tcl │ │ └── replication.tcl │ ├── modules │ │ ├── Makefile │ │ ├── auth.c │ │ ├── blockonkeys.c │ │ ├── commandfilter.c │ │ ├── datatype.c │ │ ├── fork.c │ │ ├── hooks.c │ │ ├── infotest.c │ │ ├── misc.c │ │ ├── propagate.c │ │ ├── scan.c │ │ └── testrdb.c │ ├── sentinel │ │ ├── run.tcl │ │ ├── tests │ │ │ ├── 00-base.tcl │ │ │ ├── 01-conf-update.tcl │ │ │ ├── 02-slaves-reconf.tcl │ │ │ ├── 03-runtime-reconf.tcl │ │ │ ├── 04-slave-selection.tcl │ │ │ ├── 05-manual.tcl │ │ │ ├── 06-ckquorum.tcl │ │ │ ├── 07-down-conditions.tcl │ │ │ └── includes │ │ │ │ └── init-tests.tcl │ │ └── tmp │ │ │ └── .gitignore │ ├── support │ │ ├── cli.tcl │ │ ├── cluster.tcl │ │ ├── redis.tcl │ │ ├── server.tcl │ │ ├── test.tcl │ │ ├── tmpfile.tcl │ │ └── util.tcl │ ├── test_helper.tcl │ └── unit │ │ ├── acl.tcl │ │ ├── aofrw.tcl │ │ ├── auth.tcl │ │ ├── bitfield.tcl │ │ ├── bitops.tcl │ │ ├── dump.tcl │ │ ├── expire.tcl │ │ ├── geo.tcl │ │ ├── hyperloglog.tcl │ │ ├── introspection-2.tcl │ │ ├── introspection.tcl │ │ ├── keyspace.tcl │ │ ├── latency-monitor.tcl │ │ ├── lazyfree.tcl │ │ ├── limits.tcl │ │ ├── maxmemory.tcl │ │ ├── memefficiency.tcl │ │ ├── moduleapi │ │ ├── auth.tcl │ │ ├── blockonkeys.tcl │ │ ├── commandfilter.tcl │ │ ├── datatype.tcl │ │ ├── fork.tcl │ │ ├── hooks.tcl │ │ ├── infotest.tcl │ │ ├── misc.tcl │ │ ├── propagate.tcl │ │ ├── scan.tcl │ │ └── testrdb.tcl │ │ ├── multi.tcl │ │ ├── obuf-limits.tcl │ │ ├── other.tcl │ │ ├── pendingquerybuf.tcl │ │ ├── printver.tcl │ │ ├── protocol.tcl │ │ ├── pubsub.tcl │ │ ├── quit.tcl │ │ ├── scan.tcl │ │ ├── scripting.tcl │ │ ├── slowlog.tcl │ │ ├── sort.tcl │ │ ├── tls.tcl │ │ ├── tracking.tcl │ │ ├── type │ │ ├── hash.tcl │ │ ├── incr.tcl │ │ ├── list-2.tcl │ │ ├── list-3.tcl │ │ ├── list-common.tcl │ │ ├── list.tcl │ │ ├── set.tcl │ │ ├── stream-cgroups.tcl │ │ ├── stream.tcl │ │ ├── string.tcl │ │ └── zset.tcl │ │ └── wait.tcl │ └── utils │ ├── build-static-symbols.tcl │ ├── cluster_fail_time.tcl │ ├── corrupt_rdb.c │ ├── create-cluster │ ├── .gitignore │ ├── README │ └── create-cluster │ ├── gen-test-certs.sh │ ├── generate-command-help.rb │ ├── graphs │ └── commits-over-time │ │ ├── README.md │ │ └── genhtml.tcl │ ├── hashtable │ ├── README │ └── rehashing.c │ ├── hyperloglog │ ├── .gitignore │ ├── hll-err.rb │ └── hll-gnuplot-graph.rb │ ├── install_server.sh │ ├── lru │ ├── README │ ├── lfu-simulation.c │ └── test-lru.rb │ ├── redis-copy.rb │ ├── redis-sha1.rb │ ├── redis_init_script │ ├── redis_init_script.tpl │ ├── releasetools │ ├── 01_create_tarball.sh │ ├── 02_upload_tarball.sh │ ├── 03_test_release.sh │ ├── 04_release_hash.sh │ └── changelog.tcl │ ├── speed-regression.tcl │ ├── srandmember │ ├── README.md │ ├── showdist.rb │ └── showfreq.rb │ ├── systemd-redis_multiple_servers@.service │ ├── systemd-redis_server.service │ ├── tracking_collisions.c │ └── whatisdoing.sh ├── Chapter03 └── code │ ├── .DS_Store │ ├── SharedMutex.cpp │ ├── SharedMutex.h │ ├── SingleInstance │ ├── Resource.h │ ├── SingleInstance.cpp │ ├── SingleInstance.h │ ├── SingleInstance.ico │ ├── SingleInstance.rc │ ├── SingleInstance.sln │ ├── SingleInstance.vcxproj │ ├── SingleInstance.vcxproj.filters │ ├── small.ico │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── TaskPool.cpp │ ├── TaskPool.h │ ├── TestFiber.cpp │ ├── TestSharedMutexBenchmark.cpp │ ├── TestWindowsConditionVariable │ ├── TestWindowsConditionVariable.cpp │ ├── TestWindowsConditionVariable.sln │ ├── TestWindowsConditionVariable.vcxproj │ └── TestWindowsConditionVariable.vcxproj.filters │ ├── c11mutex.cpp │ ├── c11threadlocal.cpp │ ├── cpp11cv.cpp │ ├── cv.cpp │ ├── insecurecrtfunction.cpp │ ├── linuxtid.cpp │ ├── linuxtls.cpp │ ├── linuxtls2.cpp │ ├── makesurethread.cpp │ ├── makesurethreadgroup.cpp │ ├── rwlock.cpp │ ├── rwlock2.cpp │ ├── rwlock3.cpp │ ├── semaphore.cpp │ ├── semaphore_timewait.cpp │ ├── taskpoolmain.cpp │ ├── test_cpp11_thread_id.cpp │ ├── test_destroy_locked_mutex.cpp │ └── windowstls.cpp ├── Chapter04 └── code │ ├── IOCPServerDemo │ ├── IOCPModel.cpp │ ├── IOCPModel.h │ ├── IOCPServerApp.cpp │ ├── IOCPServerApp.h │ ├── IOCPServerDemo.rc │ ├── IOCPServerDemo.sln │ ├── IOCPServerDemo.vcproj │ ├── IOCPServerDemo.vcxproj │ ├── IOCPServerDemo.vcxproj.filters │ ├── MainDlg.cpp │ ├── MainDlg.h │ ├── XPStyle.manifest │ ├── res │ │ ├── IOCPServerDemo.ico │ │ ├── IOCPServerDemo.rc2 │ │ └── vssver2.scc │ ├── resource.h │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── WSAAsyncSelect │ ├── Resource.h │ ├── WSAAsyncSelect.cpp │ ├── WSAAsyncSelect.h │ ├── WSAAsyncSelect.ico │ ├── WSAAsyncSelect.rc │ ├── WSAAsyncSelect.sln │ ├── WSAAsyncSelect.vcxproj │ ├── WSAAsyncSelect.vcxproj.filters │ ├── small.ico │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── WSAEventSelect │ ├── WSAEventSelect.cpp │ ├── WSAEventSelect.sln │ ├── WSAEventSelect.vcxproj │ ├── WSAEventSelect.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── blocking_client.cpp │ ├── blocking_client_recv.cpp │ ├── blocking_client_send.cpp │ ├── blocking_server.cpp │ ├── client.cpp │ ├── client2.cpp │ ├── epoll_server.cpp │ ├── epoll_server_with_oneshot.cpp │ ├── epoll_server_with_oneshot_2.cpp │ ├── epoll_server_write_event_et.cpp │ ├── epoll_server_write_event_lt.cpp │ ├── gethostbyname_linux.cpp │ ├── linux_ioctl.cpp │ ├── linux_nonblocking_connect.cpp │ ├── linux_nonblocking_connect_poll.cpp │ ├── nagle_client.cpp │ ├── nodelay_client.cpp │ ├── nonblocking_client.cpp │ ├── nonblocking_client_recv.cpp │ ├── nonblocking_client_send.cpp │ ├── nonblocking_client_send_zero_bytes.cpp │ ├── nonblocking_connect.cpp │ ├── poll_server.cpp │ ├── select_client_tv0.cpp │ ├── select_client_tvnull.cpp │ ├── select_server.cpp │ ├── server.cpp │ ├── server2.cpp │ └── server_recv_zero_bytes.cpp ├── Chapter06 └── code │ ├── ProtocolStream.cpp │ ├── ProtocolStream.h │ ├── RecvMail │ ├── Base64Util.cpp │ ├── Base64Util.h │ ├── EncodeUtil.cpp │ ├── EncodeUtil.h │ ├── MailHelper.cpp │ ├── MailHelper.h │ ├── MailThread.cpp │ ├── MailThread.h │ ├── Platform.cpp │ ├── Platform.h │ ├── Pop3Socket.cpp │ ├── Pop3Socket.h │ ├── RecvMail.sln │ ├── RecvMail.vcxproj │ ├── RecvMail.vcxproj.filters │ ├── mailcontent.txt │ ├── main.cpp │ ├── self.jpg │ └── test.docx │ ├── SendMail │ ├── Base64Util.cpp │ ├── Base64Util.h │ ├── CMakeLists.txt │ ├── MailMonitor.cpp │ ├── MailMonitor.h │ ├── Platform.cpp │ ├── Platform.h │ ├── SendMail.sln │ ├── SendMail.vcxproj │ ├── SendMail.vcxproj.filters │ ├── SmtpSocket.cpp │ ├── SmtpSocket.h │ └── main.cpp │ ├── WebSocketServer │ ├── CMakeLists.txt │ ├── README.md │ ├── WebSocketServer.sln │ ├── WebSocketServer.vcxproj │ ├── WebSocketServer.vcxproj.filters │ ├── appsrc │ │ ├── BusinessSession.cpp │ │ ├── BusinessSession.h │ │ └── main.cpp │ ├── base │ │ ├── AsyncLog.cpp │ │ ├── AsyncLog.h │ │ ├── ConfigFileReader.cpp │ │ ├── ConfigFileReader.h │ │ ├── Platform.cpp │ │ ├── Platform.h │ │ ├── RAIIWrapper.h │ │ ├── Singleton.h │ │ ├── Timestamp.cpp │ │ └── Timestamp.h │ ├── net │ │ ├── Acceptor.cpp │ │ ├── Acceptor.h │ │ ├── Buffer.cpp │ │ ├── Buffer.h │ │ ├── Callbacks.h │ │ ├── Channel.cpp │ │ ├── Channel.h │ │ ├── Connector.cpp │ │ ├── Connector.h │ │ ├── Endian.h │ │ ├── EpollPoller.cpp │ │ ├── EpollPoller.h │ │ ├── EventLoop.cpp │ │ ├── EventLoop.h │ │ ├── EventLoopThread.cpp │ │ ├── EventLoopThread.h │ │ ├── EventLoopThreadPool.cpp │ │ ├── EventLoopThreadPool.h │ │ ├── InetAddress.cpp │ │ ├── InetAddress.h │ │ ├── PollPoller.cpp │ │ ├── PollPoller.h │ │ ├── Poller.cpp │ │ ├── Poller.h │ │ ├── ProtocolStream.cpp │ │ ├── ProtocolStream.h │ │ ├── SelectPoller.cpp │ │ ├── SelectPoller.h │ │ ├── Sockets.cpp │ │ ├── Sockets.h │ │ ├── TcpClient.cpp │ │ ├── TcpClient.h │ │ ├── TcpConnection.cpp │ │ ├── TcpConnection.h │ │ ├── TcpServer.cpp │ │ ├── TcpServer.h │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── TimerId.h │ │ ├── TimerQueue.cpp │ │ └── TimerQueue.h │ ├── utils │ │ ├── DaemonRun.cpp │ │ ├── DaemonRun.h │ │ ├── StringUtil.cpp │ │ ├── StringUtil.h │ │ ├── UUIDGenerator.cpp │ │ └── UUIDGenerator.h │ ├── websocketsrc │ │ ├── MyWebSocketServer.cpp │ │ ├── MyWebSocketServer.h │ │ ├── MyWebSocketSession.cpp │ │ ├── MyWebSocketSession.h │ │ └── WebSocketHandshake.h │ └── zlib1.2.11 │ │ ├── ZlibUtil.cpp │ │ ├── ZlibUtil.h │ │ ├── adler32.c │ │ ├── compress.c │ │ ├── crc32.c │ │ ├── crc32.h │ │ ├── deflate.c │ │ ├── deflate.h │ │ ├── gzclose.c │ │ ├── gzguts.h │ │ ├── gzlib.c │ │ ├── gzread.c │ │ ├── gzwrite.c │ │ ├── infback.c │ │ ├── inffast.c │ │ ├── inffast.h │ │ ├── inffixed.h │ │ ├── inflate.c │ │ ├── inflate.h │ │ ├── inftrees.c │ │ ├── inftrees.h │ │ ├── trees.c │ │ ├── trees.h │ │ ├── uncompr.c │ │ ├── zconf.h │ │ ├── zlib.h │ │ ├── zlibdemo.c │ │ ├── zutil.c │ │ ├── zutil.h │ │ └── 文件概览.txt │ ├── curl │ ├── CurlClient.cpp │ ├── CurlClient.h │ ├── curl.h │ ├── curlver.h │ ├── easy.h │ ├── libcurl.dll │ ├── libcurl.lib │ ├── libcurl.so.4.5.0 │ ├── mprintf.h │ ├── multi.h │ ├── stdcheaders.h │ ├── system.h │ ├── typecheck-gcc.h │ └── urlapi.h │ └── 包分片逻辑.cpp ├── Chapter07 ├── codes │ ├── .DS_Store │ ├── timerV1 │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── TimerManager.cpp │ │ └── TimerManager.h │ ├── timerV2 │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── TimerManager.cpp │ │ └── TimerManager.h │ └── timerV3 │ │ ├── Timer.cpp │ │ ├── Timer.h │ │ ├── TimerManager.cpp │ │ └── TimerManager.h └── redis-6.0.3 │ ├── .github │ └── workflows │ │ ├── ci.yml │ │ └── daily.yml │ ├── .gitignore │ ├── 00-RELEASENOTES │ ├── BUGS │ ├── CONTRIBUTING │ ├── COPYING │ ├── INSTALL │ ├── MANIFESTO │ ├── Makefile │ ├── README.md │ ├── TLS.md │ ├── deps │ ├── Makefile │ ├── README.md │ ├── hiredis │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── CMakeLists.txt │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ ├── adapters │ │ │ ├── ae.h │ │ │ ├── glib.h │ │ │ ├── ivykis.h │ │ │ ├── libev.h │ │ │ ├── libevent.h │ │ │ ├── libuv.h │ │ │ ├── macosx.h │ │ │ └── qt.h │ │ ├── appveyor.yml │ │ ├── async.c │ │ ├── async.h │ │ ├── async_private.h │ │ ├── dict.c │ │ ├── dict.h │ │ ├── examples │ │ │ ├── CMakeLists.txt │ │ │ ├── example-ae.c │ │ │ ├── example-glib.c │ │ │ ├── example-ivykis.c │ │ │ ├── example-libev.c │ │ │ ├── example-libevent-ssl.c │ │ │ ├── example-libevent.c │ │ │ ├── example-libuv.c │ │ │ ├── example-macosx.c │ │ │ ├── example-qt.cpp │ │ │ ├── example-qt.h │ │ │ ├── example-ssl.c │ │ │ └── example.c │ │ ├── fmacros.h │ │ ├── hiredis.c │ │ ├── hiredis.h │ │ ├── hiredis.pc.in │ │ ├── hiredis_ssl.h │ │ ├── hiredis_ssl.pc.in │ │ ├── net.c │ │ ├── net.h │ │ ├── read.c │ │ ├── read.h │ │ ├── sds.c │ │ ├── sds.h │ │ ├── sdsalloc.h │ │ ├── sockcompat.c │ │ ├── sockcompat.h │ │ ├── ssl.c │ │ ├── test.c │ │ ├── test.sh │ │ └── win32.h │ ├── jemalloc │ │ ├── .appveyor.yml │ │ ├── .autom4te.cfg │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── COPYING │ │ ├── ChangeLog │ │ ├── INSTALL.md │ │ ├── Makefile.in │ │ ├── README │ │ ├── TUNING.md │ │ ├── autogen.sh │ │ ├── bin │ │ │ ├── jemalloc-config.in │ │ │ ├── jemalloc.sh.in │ │ │ └── jeprof.in │ │ ├── build-aux │ │ │ ├── config.guess │ │ │ ├── config.sub │ │ │ └── install-sh │ │ ├── config.stamp.in │ │ ├── configure.ac │ │ ├── doc │ │ │ ├── html.xsl.in │ │ │ ├── jemalloc.xml.in │ │ │ ├── manpages.xsl.in │ │ │ └── stylesheet.xsl │ │ ├── include │ │ │ ├── jemalloc │ │ │ │ ├── internal │ │ │ │ │ ├── arena_externs.h │ │ │ │ │ ├── arena_inlines_a.h │ │ │ │ │ ├── arena_inlines_b.h │ │ │ │ │ ├── arena_stats.h │ │ │ │ │ ├── arena_structs_a.h │ │ │ │ │ ├── arena_structs_b.h │ │ │ │ │ ├── arena_types.h │ │ │ │ │ ├── assert.h │ │ │ │ │ ├── atomic.h │ │ │ │ │ ├── atomic_c11.h │ │ │ │ │ ├── atomic_gcc_atomic.h │ │ │ │ │ ├── atomic_gcc_sync.h │ │ │ │ │ ├── atomic_msvc.h │ │ │ │ │ ├── background_thread_externs.h │ │ │ │ │ ├── background_thread_inlines.h │ │ │ │ │ ├── background_thread_structs.h │ │ │ │ │ ├── base_externs.h │ │ │ │ │ ├── base_inlines.h │ │ │ │ │ ├── base_structs.h │ │ │ │ │ ├── base_types.h │ │ │ │ │ ├── bin.h │ │ │ │ │ ├── bin_stats.h │ │ │ │ │ ├── bit_util.h │ │ │ │ │ ├── bitmap.h │ │ │ │ │ ├── cache_bin.h │ │ │ │ │ ├── ckh.h │ │ │ │ │ ├── ctl.h │ │ │ │ │ ├── div.h │ │ │ │ │ ├── emitter.h │ │ │ │ │ ├── extent_dss.h │ │ │ │ │ ├── extent_externs.h │ │ │ │ │ ├── extent_inlines.h │ │ │ │ │ ├── extent_mmap.h │ │ │ │ │ ├── extent_structs.h │ │ │ │ │ ├── extent_types.h │ │ │ │ │ ├── hash.h │ │ │ │ │ ├── hooks.h │ │ │ │ │ ├── jemalloc_internal_decls.h │ │ │ │ │ ├── jemalloc_internal_defs.h.in │ │ │ │ │ ├── jemalloc_internal_externs.h │ │ │ │ │ ├── jemalloc_internal_includes.h │ │ │ │ │ ├── jemalloc_internal_inlines_a.h │ │ │ │ │ ├── jemalloc_internal_inlines_b.h │ │ │ │ │ ├── jemalloc_internal_inlines_c.h │ │ │ │ │ ├── jemalloc_internal_macros.h │ │ │ │ │ ├── jemalloc_internal_types.h │ │ │ │ │ ├── jemalloc_preamble.h.in │ │ │ │ │ ├── large_externs.h │ │ │ │ │ ├── log.h │ │ │ │ │ ├── malloc_io.h │ │ │ │ │ ├── mutex.h │ │ │ │ │ ├── mutex_pool.h │ │ │ │ │ ├── mutex_prof.h │ │ │ │ │ ├── nstime.h │ │ │ │ │ ├── pages.h │ │ │ │ │ ├── ph.h │ │ │ │ │ ├── private_namespace.sh │ │ │ │ │ ├── private_symbols.sh │ │ │ │ │ ├── prng.h │ │ │ │ │ ├── prof_externs.h │ │ │ │ │ ├── prof_inlines_a.h │ │ │ │ │ ├── prof_inlines_b.h │ │ │ │ │ ├── prof_structs.h │ │ │ │ │ ├── prof_types.h │ │ │ │ │ ├── public_namespace.sh │ │ │ │ │ ├── public_unnamespace.sh │ │ │ │ │ ├── ql.h │ │ │ │ │ ├── qr.h │ │ │ │ │ ├── rb.h │ │ │ │ │ ├── rtree.h │ │ │ │ │ ├── rtree_tsd.h │ │ │ │ │ ├── size_classes.sh │ │ │ │ │ ├── smoothstep.h │ │ │ │ │ ├── smoothstep.sh │ │ │ │ │ ├── spin.h │ │ │ │ │ ├── stats.h │ │ │ │ │ ├── sz.h │ │ │ │ │ ├── tcache_externs.h │ │ │ │ │ ├── tcache_inlines.h │ │ │ │ │ ├── tcache_structs.h │ │ │ │ │ ├── tcache_types.h │ │ │ │ │ ├── ticker.h │ │ │ │ │ ├── tsd.h │ │ │ │ │ ├── tsd_generic.h │ │ │ │ │ ├── tsd_malloc_thread_cleanup.h │ │ │ │ │ ├── tsd_tls.h │ │ │ │ │ ├── tsd_types.h │ │ │ │ │ ├── tsd_win.h │ │ │ │ │ ├── util.h │ │ │ │ │ └── witness.h │ │ │ │ ├── jemalloc.sh │ │ │ │ ├── jemalloc_defs.h.in │ │ │ │ ├── jemalloc_macros.h.in │ │ │ │ ├── jemalloc_mangle.sh │ │ │ │ ├── jemalloc_protos.h.in │ │ │ │ ├── jemalloc_rename.sh │ │ │ │ └── jemalloc_typedefs.h.in │ │ │ └── msvc_compat │ │ │ │ ├── C99 │ │ │ │ ├── stdbool.h │ │ │ │ └── stdint.h │ │ │ │ ├── strings.h │ │ │ │ └── windows_extra.h │ │ ├── jemalloc.pc.in │ │ ├── m4 │ │ │ └── ax_cxx_compile_stdcxx.m4 │ │ ├── msvc │ │ │ ├── ReadMe.txt │ │ │ ├── jemalloc_vc2015.sln │ │ │ ├── jemalloc_vc2017.sln │ │ │ ├── projects │ │ │ │ ├── vc2015 │ │ │ │ │ ├── jemalloc │ │ │ │ │ │ ├── jemalloc.vcxproj │ │ │ │ │ │ └── jemalloc.vcxproj.filters │ │ │ │ │ └── test_threads │ │ │ │ │ │ ├── test_threads.vcxproj │ │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ │ └── vc2017 │ │ │ │ │ ├── jemalloc │ │ │ │ │ ├── jemalloc.vcxproj │ │ │ │ │ └── jemalloc.vcxproj.filters │ │ │ │ │ └── test_threads │ │ │ │ │ ├── test_threads.vcxproj │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ └── test_threads │ │ │ │ ├── test_threads.cpp │ │ │ │ ├── test_threads.h │ │ │ │ └── test_threads_main.cpp │ │ ├── run_tests.sh │ │ ├── scripts │ │ │ ├── gen_run_tests.py │ │ │ └── gen_travis.py │ │ ├── src │ │ │ ├── arena.c │ │ │ ├── background_thread.c │ │ │ ├── base.c │ │ │ ├── bin.c │ │ │ ├── bitmap.c │ │ │ ├── ckh.c │ │ │ ├── ctl.c │ │ │ ├── div.c │ │ │ ├── extent.c │ │ │ ├── extent_dss.c │ │ │ ├── extent_mmap.c │ │ │ ├── hash.c │ │ │ ├── hooks.c │ │ │ ├── jemalloc.c │ │ │ ├── jemalloc_cpp.cpp │ │ │ ├── large.c │ │ │ ├── log.c │ │ │ ├── malloc_io.c │ │ │ ├── mutex.c │ │ │ ├── mutex_pool.c │ │ │ ├── nstime.c │ │ │ ├── pages.c │ │ │ ├── prng.c │ │ │ ├── prof.c │ │ │ ├── rtree.c │ │ │ ├── stats.c │ │ │ ├── sz.c │ │ │ ├── tcache.c │ │ │ ├── ticker.c │ │ │ ├── tsd.c │ │ │ ├── witness.c │ │ │ └── zone.c │ │ └── test │ │ │ ├── include │ │ │ └── test │ │ │ │ ├── SFMT-alti.h │ │ │ │ ├── SFMT-params.h │ │ │ │ ├── SFMT-params11213.h │ │ │ │ ├── SFMT-params1279.h │ │ │ │ ├── SFMT-params132049.h │ │ │ │ ├── SFMT-params19937.h │ │ │ │ ├── SFMT-params216091.h │ │ │ │ ├── SFMT-params2281.h │ │ │ │ ├── SFMT-params4253.h │ │ │ │ ├── SFMT-params44497.h │ │ │ │ ├── SFMT-params607.h │ │ │ │ ├── SFMT-params86243.h │ │ │ │ ├── SFMT-sse2.h │ │ │ │ ├── SFMT.h │ │ │ │ ├── btalloc.h │ │ │ │ ├── extent_hooks.h │ │ │ │ ├── jemalloc_test.h.in │ │ │ │ ├── jemalloc_test_defs.h.in │ │ │ │ ├── math.h │ │ │ │ ├── mq.h │ │ │ │ ├── mtx.h │ │ │ │ ├── test.h │ │ │ │ ├── thd.h │ │ │ │ └── timer.h │ │ │ ├── integration │ │ │ ├── MALLOCX_ARENA.c │ │ │ ├── aligned_alloc.c │ │ │ ├── allocated.c │ │ │ ├── extent.c │ │ │ ├── extent.sh │ │ │ ├── mallocx.c │ │ │ ├── mallocx.sh │ │ │ ├── overflow.c │ │ │ ├── posix_memalign.c │ │ │ ├── rallocx.c │ │ │ ├── sdallocx.c │ │ │ ├── thread_arena.c │ │ │ ├── thread_tcache_enabled.c │ │ │ ├── xallocx.c │ │ │ └── xallocx.sh │ │ │ ├── src │ │ │ ├── SFMT.c │ │ │ ├── btalloc.c │ │ │ ├── btalloc_0.c │ │ │ ├── btalloc_1.c │ │ │ ├── math.c │ │ │ ├── mq.c │ │ │ ├── mtx.c │ │ │ ├── test.c │ │ │ ├── thd.c │ │ │ └── timer.c │ │ │ ├── stress │ │ │ └── microbench.c │ │ │ ├── test.sh.in │ │ │ └── unit │ │ │ ├── SFMT.c │ │ │ ├── a0.c │ │ │ ├── arena_reset.c │ │ │ ├── arena_reset_prof.c │ │ │ ├── arena_reset_prof.sh │ │ │ ├── atomic.c │ │ │ ├── background_thread.c │ │ │ ├── background_thread_enable.c │ │ │ ├── base.c │ │ │ ├── bit_util.c │ │ │ ├── bitmap.c │ │ │ ├── ckh.c │ │ │ ├── decay.c │ │ │ ├── decay.sh │ │ │ ├── div.c │ │ │ ├── emitter.c │ │ │ ├── extent_quantize.c │ │ │ ├── fork.c │ │ │ ├── hash.c │ │ │ ├── hooks.c │ │ │ ├── junk.c │ │ │ ├── junk.sh │ │ │ ├── junk_alloc.c │ │ │ ├── junk_alloc.sh │ │ │ ├── junk_free.c │ │ │ ├── junk_free.sh │ │ │ ├── log.c │ │ │ ├── mallctl.c │ │ │ ├── malloc_io.c │ │ │ ├── math.c │ │ │ ├── mq.c │ │ │ ├── mtx.c │ │ │ ├── nstime.c │ │ │ ├── pack.c │ │ │ ├── pack.sh │ │ │ ├── pages.c │ │ │ ├── ph.c │ │ │ ├── prng.c │ │ │ ├── prof_accum.c │ │ │ ├── prof_accum.sh │ │ │ ├── prof_active.c │ │ │ ├── prof_active.sh │ │ │ ├── prof_gdump.c │ │ │ ├── prof_gdump.sh │ │ │ ├── prof_idump.c │ │ │ ├── prof_idump.sh │ │ │ ├── prof_reset.c │ │ │ ├── prof_reset.sh │ │ │ ├── prof_tctx.c │ │ │ ├── prof_tctx.sh │ │ │ ├── prof_thread_name.c │ │ │ ├── prof_thread_name.sh │ │ │ ├── ql.c │ │ │ ├── qr.c │ │ │ ├── rb.c │ │ │ ├── retained.c │ │ │ ├── rtree.c │ │ │ ├── size_classes.c │ │ │ ├── slab.c │ │ │ ├── smoothstep.c │ │ │ ├── spin.c │ │ │ ├── stats.c │ │ │ ├── stats_print.c │ │ │ ├── ticker.c │ │ │ ├── tsd.c │ │ │ ├── witness.c │ │ │ ├── zero.c │ │ │ └── zero.sh │ ├── linenoise │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── README.markdown │ │ ├── example.c │ │ ├── linenoise.c │ │ └── linenoise.h │ ├── lua │ │ ├── COPYRIGHT │ │ ├── HISTORY │ │ ├── INSTALL │ │ ├── Makefile │ │ ├── README │ │ ├── doc │ │ │ ├── contents.html │ │ │ ├── cover.png │ │ │ ├── logo.gif │ │ │ ├── lua.1 │ │ │ ├── lua.css │ │ │ ├── lua.html │ │ │ ├── luac.1 │ │ │ ├── luac.html │ │ │ ├── manual.css │ │ │ ├── manual.html │ │ │ └── readme.html │ │ ├── etc │ │ │ ├── Makefile │ │ │ ├── README │ │ │ ├── all.c │ │ │ ├── lua.hpp │ │ │ ├── lua.ico │ │ │ ├── lua.pc │ │ │ ├── luavs.bat │ │ │ ├── min.c │ │ │ ├── noparser.c │ │ │ └── strict.lua │ │ ├── src │ │ │ ├── Makefile │ │ │ ├── fpconv.c │ │ │ ├── fpconv.h │ │ │ ├── lapi.c │ │ │ ├── lapi.h │ │ │ ├── lauxlib.c │ │ │ ├── lauxlib.h │ │ │ ├── lbaselib.c │ │ │ ├── lcode.c │ │ │ ├── lcode.h │ │ │ ├── ldblib.c │ │ │ ├── ldebug.c │ │ │ ├── ldebug.h │ │ │ ├── ldo.c │ │ │ ├── ldo.h │ │ │ ├── ldump.c │ │ │ ├── lfunc.c │ │ │ ├── lfunc.h │ │ │ ├── lgc.c │ │ │ ├── lgc.h │ │ │ ├── linit.c │ │ │ ├── liolib.c │ │ │ ├── llex.c │ │ │ ├── llex.h │ │ │ ├── llimits.h │ │ │ ├── lmathlib.c │ │ │ ├── lmem.c │ │ │ ├── lmem.h │ │ │ ├── loadlib.c │ │ │ ├── lobject.c │ │ │ ├── lobject.h │ │ │ ├── lopcodes.c │ │ │ ├── lopcodes.h │ │ │ ├── loslib.c │ │ │ ├── lparser.c │ │ │ ├── lparser.h │ │ │ ├── lstate.c │ │ │ ├── lstate.h │ │ │ ├── lstring.c │ │ │ ├── lstring.h │ │ │ ├── lstrlib.c │ │ │ ├── ltable.c │ │ │ ├── ltable.h │ │ │ ├── ltablib.c │ │ │ ├── ltm.c │ │ │ ├── ltm.h │ │ │ ├── lua.c │ │ │ ├── lua.h │ │ │ ├── lua_bit.c │ │ │ ├── lua_cjson.c │ │ │ ├── lua_cmsgpack.c │ │ │ ├── lua_struct.c │ │ │ ├── luac.c │ │ │ ├── luaconf.h │ │ │ ├── lualib.h │ │ │ ├── lundump.c │ │ │ ├── lundump.h │ │ │ ├── lvm.c │ │ │ ├── lvm.h │ │ │ ├── lzio.c │ │ │ ├── lzio.h │ │ │ ├── print.c │ │ │ ├── strbuf.c │ │ │ └── strbuf.h │ │ └── test │ │ │ ├── README │ │ │ ├── bisect.lua │ │ │ ├── cf.lua │ │ │ ├── echo.lua │ │ │ ├── env.lua │ │ │ ├── factorial.lua │ │ │ ├── fib.lua │ │ │ ├── fibfor.lua │ │ │ ├── globals.lua │ │ │ ├── hello.lua │ │ │ ├── life.lua │ │ │ ├── luac.lua │ │ │ ├── printf.lua │ │ │ ├── readonly.lua │ │ │ ├── sieve.lua │ │ │ ├── sort.lua │ │ │ ├── table.lua │ │ │ ├── trace-calls.lua │ │ │ ├── trace-globals.lua │ │ │ └── xd.lua │ └── update-jemalloc.sh │ ├── redis.conf │ ├── runtest │ ├── runtest-cluster │ ├── runtest-moduleapi │ ├── runtest-sentinel │ ├── sentinel.conf │ ├── src │ ├── .gitignore │ ├── Makefile │ ├── acl.c │ ├── adlist.c │ ├── adlist.h │ ├── ae.c │ ├── ae.h │ ├── ae_epoll.c │ ├── ae_evport.c │ ├── ae_kqueue.c │ ├── ae_select.c │ ├── anet.c │ ├── anet.h │ ├── aof.c │ ├── asciilogo.h │ ├── atomicvar.h │ ├── bio.c │ ├── bio.h │ ├── bitops.c │ ├── blocked.c │ ├── childinfo.c │ ├── cluster.c │ ├── cluster.h │ ├── config.c │ ├── config.h │ ├── connection.c │ ├── connection.h │ ├── connhelpers.h │ ├── crc16.c │ ├── crc16_slottable.h │ ├── crc64.c │ ├── crc64.h │ ├── crcspeed.c │ ├── crcspeed.h │ ├── db.c │ ├── debug.c │ ├── debugmacro.h │ ├── defrag.c │ ├── dict.c │ ├── dict.h │ ├── endianconv.c │ ├── endianconv.h │ ├── evict.c │ ├── expire.c │ ├── fmacros.h │ ├── geo.c │ ├── geo.h │ ├── geohash.c │ ├── geohash.h │ ├── geohash_helper.c │ ├── geohash_helper.h │ ├── gopher.c │ ├── help.h │ ├── hyperloglog.c │ ├── intset.c │ ├── intset.h │ ├── latency.c │ ├── latency.h │ ├── lazyfree.c │ ├── listpack.c │ ├── listpack.h │ ├── listpack_malloc.h │ ├── localtime.c │ ├── lolwut.c │ ├── lolwut.h │ ├── lolwut5.c │ ├── lolwut6.c │ ├── lzf.h │ ├── lzfP.h │ ├── lzf_c.c │ ├── lzf_d.c │ ├── memtest.c │ ├── mkreleasehdr.sh │ ├── module.c │ ├── modules │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── gendoc.rb │ │ ├── helloacl.c │ │ ├── helloblock.c │ │ ├── hellocluster.c │ │ ├── hellodict.c │ │ ├── hellohook.c │ │ ├── hellotimer.c │ │ ├── hellotype.c │ │ ├── helloworld.c │ │ └── testmodule.c │ ├── multi.c │ ├── networking.c │ ├── notify.c │ ├── object.c │ ├── pqsort.c │ ├── pqsort.h │ ├── pubsub.c │ ├── quicklist.c │ ├── quicklist.h │ ├── rand.c │ ├── rand.h │ ├── rax.c │ ├── rax.h │ ├── rax_malloc.h │ ├── rdb.c │ ├── rdb.h │ ├── redis-benchmark.c │ ├── redis-check-aof.c │ ├── redis-check-rdb.c │ ├── redis-cli.c │ ├── redis-trib.rb │ ├── redisassert.h │ ├── redismodule.h │ ├── release.c │ ├── replication.c │ ├── rio.c │ ├── rio.h │ ├── scripting.c │ ├── sds.c │ ├── sds.h │ ├── sdsalloc.h │ ├── sentinel.c │ ├── server.c │ ├── server.h │ ├── setcpuaffinity.c │ ├── setproctitle.c │ ├── sha1.c │ ├── sha1.h │ ├── sha256.c │ ├── sha256.h │ ├── siphash.c │ ├── slowlog.c │ ├── slowlog.h │ ├── solarisfixes.h │ ├── sort.c │ ├── sparkline.c │ ├── sparkline.h │ ├── stream.h │ ├── syncio.c │ ├── t_hash.c │ ├── t_list.c │ ├── t_set.c │ ├── t_stream.c │ ├── t_string.c │ ├── t_zset.c │ ├── testhelp.h │ ├── timeout.c │ ├── tls.c │ ├── tracking.c │ ├── util.c │ ├── util.h │ ├── valgrind.sup │ ├── version.h │ ├── ziplist.c │ ├── ziplist.h │ ├── zipmap.c │ ├── zipmap.h │ ├── zmalloc.c │ └── zmalloc.h │ ├── tests │ ├── assets │ │ ├── default.conf │ │ ├── encodings.rdb │ │ └── hash-zipmap.rdb │ ├── cluster │ │ ├── cluster.tcl │ │ ├── run.tcl │ │ ├── tests │ │ │ ├── 00-base.tcl │ │ │ ├── 01-faildet.tcl │ │ │ ├── 02-failover.tcl │ │ │ ├── 03-failover-loop.tcl │ │ │ ├── 04-resharding.tcl │ │ │ ├── 05-slave-selection.tcl │ │ │ ├── 06-slave-stop-cond.tcl │ │ │ ├── 07-replica-migration.tcl │ │ │ ├── 08-update-msg.tcl │ │ │ ├── 09-pubsub.tcl │ │ │ ├── 10-manual-failover.tcl │ │ │ ├── 11-manual-takeover.tcl │ │ │ ├── 12-replica-migration-2.tcl │ │ │ ├── 13-no-failover-option.tcl │ │ │ ├── 14-consistency-check.tcl │ │ │ ├── 15-cluster-slots.tcl │ │ │ ├── helpers │ │ │ │ └── onlydots.tcl │ │ │ └── includes │ │ │ │ └── init-tests.tcl │ │ └── tmp │ │ │ └── .gitignore │ ├── helpers │ │ ├── bg_block_op.tcl │ │ ├── bg_complex_data.tcl │ │ └── gen_write_load.tcl │ ├── instances.tcl │ ├── integration │ │ ├── aof-race.tcl │ │ ├── aof.tcl │ │ ├── block-repl.tcl │ │ ├── convert-zipmap-hash-on-load.tcl │ │ ├── logging.tcl │ │ ├── psync2-pingoff.tcl │ │ ├── psync2-reg.tcl │ │ ├── psync2.tcl │ │ ├── rdb.tcl │ │ ├── redis-cli.tcl │ │ ├── replication-2.tcl │ │ ├── replication-3.tcl │ │ ├── replication-4.tcl │ │ ├── replication-psync.tcl │ │ └── replication.tcl │ ├── modules │ │ ├── Makefile │ │ ├── auth.c │ │ ├── blockonkeys.c │ │ ├── commandfilter.c │ │ ├── datatype.c │ │ ├── fork.c │ │ ├── hooks.c │ │ ├── infotest.c │ │ ├── misc.c │ │ ├── propagate.c │ │ ├── scan.c │ │ └── testrdb.c │ ├── sentinel │ │ ├── run.tcl │ │ ├── tests │ │ │ ├── 00-base.tcl │ │ │ ├── 01-conf-update.tcl │ │ │ ├── 02-slaves-reconf.tcl │ │ │ ├── 03-runtime-reconf.tcl │ │ │ ├── 04-slave-selection.tcl │ │ │ ├── 05-manual.tcl │ │ │ ├── 06-ckquorum.tcl │ │ │ ├── 07-down-conditions.tcl │ │ │ └── includes │ │ │ │ └── init-tests.tcl │ │ └── tmp │ │ │ └── .gitignore │ ├── support │ │ ├── cli.tcl │ │ ├── cluster.tcl │ │ ├── redis.tcl │ │ ├── server.tcl │ │ ├── test.tcl │ │ ├── tmpfile.tcl │ │ └── util.tcl │ ├── test_helper.tcl │ └── unit │ │ ├── acl.tcl │ │ ├── aofrw.tcl │ │ ├── auth.tcl │ │ ├── bitfield.tcl │ │ ├── bitops.tcl │ │ ├── dump.tcl │ │ ├── expire.tcl │ │ ├── geo.tcl │ │ ├── hyperloglog.tcl │ │ ├── introspection-2.tcl │ │ ├── introspection.tcl │ │ ├── keyspace.tcl │ │ ├── latency-monitor.tcl │ │ ├── lazyfree.tcl │ │ ├── limits.tcl │ │ ├── maxmemory.tcl │ │ ├── memefficiency.tcl │ │ ├── moduleapi │ │ ├── auth.tcl │ │ ├── blockonkeys.tcl │ │ ├── commandfilter.tcl │ │ ├── datatype.tcl │ │ ├── fork.tcl │ │ ├── hooks.tcl │ │ ├── infotest.tcl │ │ ├── misc.tcl │ │ ├── propagate.tcl │ │ ├── scan.tcl │ │ └── testrdb.tcl │ │ ├── multi.tcl │ │ ├── obuf-limits.tcl │ │ ├── other.tcl │ │ ├── pendingquerybuf.tcl │ │ ├── printver.tcl │ │ ├── protocol.tcl │ │ ├── pubsub.tcl │ │ ├── quit.tcl │ │ ├── scan.tcl │ │ ├── scripting.tcl │ │ ├── slowlog.tcl │ │ ├── sort.tcl │ │ ├── tls.tcl │ │ ├── tracking.tcl │ │ ├── type │ │ ├── hash.tcl │ │ ├── incr.tcl │ │ ├── list-2.tcl │ │ ├── list-3.tcl │ │ ├── list-common.tcl │ │ ├── list.tcl │ │ ├── set.tcl │ │ ├── stream-cgroups.tcl │ │ ├── stream.tcl │ │ ├── string.tcl │ │ └── zset.tcl │ │ └── wait.tcl │ └── utils │ ├── build-static-symbols.tcl │ ├── cluster_fail_time.tcl │ ├── corrupt_rdb.c │ ├── create-cluster │ ├── .gitignore │ ├── README │ └── create-cluster │ ├── gen-test-certs.sh │ ├── generate-command-help.rb │ ├── graphs │ └── commits-over-time │ │ ├── README.md │ │ └── genhtml.tcl │ ├── hashtable │ ├── README │ └── rehashing.c │ ├── hyperloglog │ ├── .gitignore │ ├── hll-err.rb │ └── hll-gnuplot-graph.rb │ ├── install_server.sh │ ├── lru │ ├── README │ ├── lfu-simulation.c │ └── test-lru.rb │ ├── redis-copy.rb │ ├── redis-sha1.rb │ ├── redis_init_script │ ├── redis_init_script.tpl │ ├── releasetools │ ├── 01_create_tarball.sh │ ├── 02_upload_tarball.sh │ ├── 03_test_release.sh │ ├── 04_release_hash.sh │ └── changelog.tcl │ ├── speed-regression.tcl │ ├── srandmember │ ├── README.md │ ├── showdist.rb │ └── showfreq.rb │ ├── systemd-redis_multiple_servers@.service │ ├── systemd-redis_server.service │ ├── tracking_collisions.c │ └── whatisdoing.sh ├── Chapter09 └── code │ ├── AsyncLogger │ ├── AsyncLogger.cpp │ ├── AsyncLogger.sln │ ├── AsyncLogger.vcxproj │ ├── AsyncLogger.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── AsyncLogger1 │ ├── AsyncLogger.cpp │ ├── AsyncLogger.sln │ ├── AsyncLogger.vcxproj │ ├── AsyncLogger.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h │ ├── AsyncLoggerLinux.cpp │ └── AsyncLoggerWindows │ ├── AsyncLogger.cpp │ ├── AsyncLogger.sln │ ├── AsyncLogger.vcxproj │ ├── AsyncLogger.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ └── targetver.h ├── README.md ├── bookCover.jpeg ├── easyserverdev.png └── 图书勘误 └── 图书勘误.docx.zip /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Chapter01/.DS_Store 3 | Chapter02/.DS_Store 4 | Chapter03/.DS_Store 5 | Chapter04/.DS_Store 6 | Chapter06/.DS_Store 7 | Chapter07/.DS_Store 8 | Chapter09/.DS_Store 9 | 图书勘误/图书勘误.docx 10 | 图书勘误/~$图书勘误.docx 11 | -------------------------------------------------------------------------------- /Chapter01/codes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/.DS_Store -------------------------------------------------------------------------------- /Chapter01/codes/TestRAII1/TestRAII3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/TestRAII1/TestRAII3.cpp -------------------------------------------------------------------------------- /Chapter01/codes/TestRAII1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TestRAII1.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter01/codes/TestRAII1/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /Chapter01/codes/TestRAII1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter01/codes/test_auto_ptr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_auto_ptr.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_custom_foreach_loop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | template 5 | class A 6 | { 7 | public: 8 | A() 9 | { 10 | for (size_t i = 0; i < N; ++i) 11 | { 12 | m_elements[i] = i; 13 | } 14 | } 15 | 16 | ~A() 17 | { 18 | 19 | } 20 | 21 | T* begin() 22 | { 23 | return m_elements + 0; 24 | } 25 | 26 | T* end() 27 | { 28 | return m_elements + N; 29 | } 30 | 31 | private: 32 | T m_elements[N]; 33 | }; 34 | 35 | int main() 36 | { 37 | A a; 38 | for (auto iter : a) 39 | { 40 | std::cout << iter << std::endl; 41 | } 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Chapter01/codes/test_map_insert_or_assign.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_map_insert_or_assign.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_map_try_emplace.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_map_try_emplace.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_map_try_emplace_with_directobject.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_map_try_emplace_with_directobject.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_map_try_emplace_with_smartpointer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_map_try_emplace_with_smartpointer.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_map_try_emplace_with_smartpointer2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_map_try_emplace_with_smartpointer2.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_shared_ptr_use_count.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_shared_ptr_use_count.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_std_enable_shared_from_this.cpp: -------------------------------------------------------------------------------- 1 | // test_std_enable_shared_from_this.cpp 2 | #include 3 | #include 4 | 5 | class A : public std::enable_shared_from_this 6 | { 7 | public: 8 | A() 9 | { 10 | std::cout << "A constructor" << std::endl; 11 | } 12 | 13 | ~A() 14 | { 15 | std::cout << "A destructor" << std::endl; 16 | } 17 | 18 | std::shared_ptr getSelf() 19 | { 20 | return shared_from_this(); 21 | } 22 | }; 23 | 24 | 25 | int main() 26 | { 27 | std::shared_ptr sp1(new A()); 28 | 29 | std::shared_ptr sp2 = sp1->getSelf(); 30 | 31 | std::cout << "use count: " << sp1.use_count() << std::endl; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Chapter01/codes/test_std_enable_shared_from_this_problem.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_std_enable_shared_from_this_problem.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_unique_ptr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_unique_ptr.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_unique_ptr_deletor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_unique_ptr_deletor.cpp -------------------------------------------------------------------------------- /Chapter01/codes/test_unique_ptr_with_array.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | //创建10个int类型的堆对象 7 | //形式1 8 | std::unique_ptr sp1(new int[10]); 9 | 10 | //形式2 11 | std::unique_ptr sp2; 12 | sp2.reset(new int[10]); 13 | //形式3 14 | std::unique_ptr sp3(std::make_unique(10)); 15 | 16 | for (int i = 0; i < 10; ++i) 17 | { 18 | sp1[i] = i; 19 | sp2[i] = i; 20 | sp3[i] = i; 21 | } 22 | 23 | for (int i = 0; i < 10; ++i) 24 | { 25 | std::cout << sp1[i] << ", " << sp2[i] << ", " << sp3[i] << std::endl; 26 | } 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Chapter01/codes/test_weak_ptr.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter01/codes/test_weak_ptr.cpp -------------------------------------------------------------------------------- /Chapter02/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/.DS_Store -------------------------------------------------------------------------------- /Chapter02/VisualGDB 下载与安装.md: -------------------------------------------------------------------------------- 1 | # VisualGDB 下载与安装 2 | 3 | ## VisualGDB 官网 4 | 5 | ``` 6 | https://visualgdb.com/ 7 | ``` 8 | 9 | 10 | 11 | ## 网络上流传的破解版 12 | 13 | > 链接: https://pan.baidu.com/s/1RlefT8_bXIpqlKrWTNP4bg 密码: ojto 14 | 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test-ubuntu-latest: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - name: make 11 | run: make 12 | - name: test 13 | run: | 14 | sudo apt-get install tcl8.5 15 | ./runtest --verbose 16 | - name: module api test 17 | run: ./runtest-moduleapi --verbose 18 | 19 | build-ubuntu-old: 20 | runs-on: ubuntu-16.04 21 | steps: 22 | - uses: actions/checkout@v1 23 | - name: make 24 | run: make 25 | 26 | build-macos-latest: 27 | runs-on: macos-latest 28 | steps: 29 | - uses: actions/checkout@v1 30 | - name: make 31 | run: make 32 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.xo 4 | *.so 5 | *.d 6 | *.log 7 | dump.rdb 8 | redis-benchmark 9 | redis-check-aof 10 | redis-check-rdb 11 | redis-check-dump 12 | redis-cli 13 | redis-sentinel 14 | redis-server 15 | doc-tools 16 | release 17 | misc/* 18 | src/release.h 19 | appendonly.aof 20 | SHORT_TERM_TODO 21 | release.h 22 | src/transfer.sh 23 | src/configs 24 | redis.ds 25 | src/redis.conf 26 | src/nodes.conf 27 | deps/lua/src/lua 28 | deps/lua/src/luac 29 | deps/lua/src/liblua.a 30 | .make-* 31 | .prerequisites 32 | *.dSYM 33 | Makefile.dep 34 | .vscode/* 35 | .idea/* 36 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/BUGS: -------------------------------------------------------------------------------- 1 | Please check https://github.com/antirez/redis/issues 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/INSTALL: -------------------------------------------------------------------------------- 1 | See README 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/Makefile: -------------------------------------------------------------------------------- 1 | # Top level makefile, the real shit is at src/Makefile 2 | 3 | default: all 4 | 5 | .DEFAULT: 6 | cd src && $(MAKE) $@ 7 | 8 | install: 9 | cd src && $(MAKE) $@ 10 | 11 | .PHONY: install 12 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /examples/hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | /*.pc 8 | *.dSYM 9 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/hiredis/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration file for CI build of hiredis on Windows (under Cygwin) 2 | environment: 3 | matrix: 4 | - CYG_BASH: C:\cygwin64\bin\bash 5 | CC: gcc 6 | - CYG_BASH: C:\cygwin\bin\bash 7 | CC: gcc 8 | CFLAGS: -m32 9 | CXXFLAGS: -m32 10 | LDFLAGS: -m32 11 | 12 | clone_depth: 1 13 | 14 | # Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail 15 | init: 16 | - git config --global core.autocrlf input 17 | 18 | # Install needed build dependencies 19 | install: 20 | - '%CYG_BASH% -lc "cygcheck -dc cygwin"' 21 | 22 | build_script: 23 | - 'echo building...' 24 | - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 5 | 6 | class ExampleQt : public QObject { 7 | 8 | Q_OBJECT 9 | 10 | public: 11 | ExampleQt(const char * value, QObject * parent = 0) 12 | : QObject(parent), m_value(value) {} 13 | 14 | signals: 15 | void finished(); 16 | 17 | public slots: 18 | void run(); 19 | 20 | private: 21 | void finish() { emit finished(); } 22 | 23 | private: 24 | const char * m_value; 25 | redisAsyncContext * m_ctx; 26 | RedisQtAdapter m_adapter; 27 | 28 | friend 29 | void getCallback(redisAsyncContext *, void *, void *); 30 | }; 31 | 32 | #endif /* !__HIREDIS_EXAMPLE_QT_H */ 33 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #define _XOPEN_SOURCE 600 5 | #define _POSIX_C_SOURCE 200112L 6 | 7 | #if defined(__APPLE__) && defined(__MACH__) 8 | /* Enable TCP_KEEPALIVE */ 9 | #define _DARWIN_C_SOURCE 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/hiredis/hiredis.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis 8 | Description: Minimalistic C client library for Redis. 9 | Version: @PROJECT_VERSION@ 10 | Libs: -L${libdir} -lhiredis 11 | Cflags: -I${pkgincludedir} -D_FILE_OFFSET_BITS=64 12 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/hiredis/hiredis_ssl.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis_ssl 8 | Description: SSL Support for hiredis. 9 | Version: @PROJECT_VERSION@ 10 | Requires: hiredis 11 | Libs: -L${libdir} -lhiredis_ssl 12 | Libs.private: -lssl -lcrypto 13 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/.autom4te.cfg: -------------------------------------------------------------------------------- 1 | begin-language: "Autoconf-without-aclocal-m4" 2 | args: --no-cache 3 | end-language: "Autoconf-without-aclocal-m4" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/config.stamp.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/deps/jemalloc/config.stamp.in -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/arena_structs_a.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 2 | #define JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 3 | 4 | #include "jemalloc/internal/bitmap.h" 5 | 6 | struct arena_slab_data_s { 7 | /* Per region allocated/deallocated bitmap. */ 8 | bitmap_t bitmap[BITMAP_GROUPS_MAX]; 9 | }; 10 | 11 | #endif /* JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H */ 12 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/base_inlines.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_INLINES_H 2 | #define JEMALLOC_INTERNAL_BASE_INLINES_H 3 | 4 | static inline unsigned 5 | base_ind_get(const base_t *base) { 6 | return base->ind; 7 | } 8 | 9 | static inline bool 10 | metadata_thp_enabled(void) { 11 | return (opt_metadata_thp != metadata_thp_disabled); 12 | } 13 | #endif /* JEMALLOC_INTERNAL_BASE_INLINES_H */ 14 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/extent_mmap.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 3 | 4 | extern bool opt_retain; 5 | 6 | void *extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, 7 | bool *zero, bool *commit); 8 | bool extent_dalloc_mmap(void *addr, size_t size); 9 | 10 | #endif /* JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H */ 11 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/extent_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_TYPES_H 2 | #define JEMALLOC_INTERNAL_EXTENT_TYPES_H 3 | 4 | typedef struct extent_s extent_t; 5 | typedef struct extents_s extents_t; 6 | 7 | #define EXTENT_HOOKS_INITIALIZER NULL 8 | 9 | #define EXTENT_GROW_MAX_PIND (NPSIZES - 1) 10 | 11 | /* 12 | * When reuse (and split) an active extent, (1U << opt_lg_extent_max_active_fit) 13 | * is the max ratio between the size of the active extent and the new extent. 14 | */ 15 | #define LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT 6 16 | 17 | #endif /* JEMALLOC_INTERNAL_EXTENT_TYPES_H */ 18 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/private_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat "$@"` ; do 4 | echo "#define ${symbol} JEMALLOC_N(${symbol})" 5 | done 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/public_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#define je_${n} JEMALLOC_N(${n})" 6 | done 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/public_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#undef je_${n}" 6 | done 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/spin.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_SPIN_H 2 | #define JEMALLOC_INTERNAL_SPIN_H 3 | 4 | #define SPIN_INITIALIZER {0U} 5 | 6 | typedef struct { 7 | unsigned iteration; 8 | } spin_t; 9 | 10 | static inline void 11 | spin_cpu_spinwait() { 12 | # if HAVE_CPU_SPINWAIT 13 | CPU_SPINWAIT; 14 | # else 15 | volatile int x = 0; 16 | x = x; 17 | # endif 18 | } 19 | 20 | static inline void 21 | spin_adaptive(spin_t *spin) { 22 | volatile uint32_t i; 23 | 24 | if (spin->iteration < 5) { 25 | for (i = 0; i < (1U << spin->iteration); i++) { 26 | spin_cpu_spinwait(); 27 | } 28 | spin->iteration++; 29 | } else { 30 | #ifdef _WIN32 31 | SwitchToThread(); 32 | #else 33 | sched_yield(); 34 | #endif 35 | } 36 | } 37 | 38 | #undef SPIN_INLINE 39 | 40 | #endif /* JEMALLOC_INTERNAL_SPIN_H */ 41 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/tsd_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_TSD_TYPES_H 2 | #define JEMALLOC_INTERNAL_TSD_TYPES_H 3 | 4 | #define MALLOC_TSD_CLEANUPS_MAX 2 5 | 6 | typedef struct tsd_s tsd_t; 7 | typedef struct tsdn_s tsdn_t; 8 | typedef bool (*malloc_tsd_cleanup_t)(void); 9 | 10 | #endif /* JEMALLOC_INTERNAL_TSD_TYPES_H */ 11 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/jemalloc/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | objroot=$1 4 | 5 | cat < 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | /* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as 9 | * a built-in type. */ 10 | #ifndef __clang__ 11 | typedef BOOL _Bool; 12 | #endif 13 | 14 | #define bool _Bool 15 | #define true 1 16 | #define false 0 17 | 18 | #define __bool_true_false_are_defined 1 19 | 20 | #endif /* stdbool_h */ 21 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/include/msvc_compat/windows_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H 2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H 3 | 4 | #include 5 | 6 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */ 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/jemalloc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | install_suffix=@install_suffix@ 6 | 7 | Name: jemalloc 8 | Description: A general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. 9 | URL: http://jemalloc.net/ 10 | Version: @jemalloc_version_major@.@jemalloc_version_minor@.@jemalloc_version_bugfix@_@jemalloc_version_nrev@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/msvc/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | How to build jemalloc for Windows 3 | ================================= 4 | 5 | 1. Install Cygwin with at least the following packages: 6 | * autoconf 7 | * autogen 8 | * gawk 9 | * grep 10 | * sed 11 | 12 | 2. Install Visual Studio 2015 or 2017 with Visual C++ 13 | 14 | 3. Add Cygwin\bin to the PATH environment variable 15 | 16 | 4. Open "x64 Native Tools Command Prompt for VS 2017" 17 | (note: x86/x64 doesn't matter at this point) 18 | 19 | 5. Generate header files: 20 | sh -c "CC=cl ./autogen.sh" 21 | 22 | 6. Now the project can be opened and built in Visual Studio: 23 | msvc\jemalloc_vc2017.sln 24 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/msvc/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/msvc/test_threads/test_threads_main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_threads.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono_literals; 7 | 8 | int main(int argc, char** argv) { 9 | int rc = test_threads(); 10 | return rc; 11 | } 12 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/run_tests.sh: -------------------------------------------------------------------------------- 1 | $(dirname "$)")/scripts/gen_run_tests.py | bash 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/src/hooks.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | 3 | /* 4 | * The hooks are a little bit screwy -- they're not genuinely exported in the 5 | * sense that we want them available to end-users, but we do want them visible 6 | * from outside the generated library, so that we can use them in test code. 7 | */ 8 | JEMALLOC_EXPORT 9 | void (*hooks_arena_new_hook)() = NULL; 10 | 11 | JEMALLOC_EXPORT 12 | void (*hooks_libc_hook)() = NULL; 13 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/src/mutex_pool.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MUTEX_POOL_C_ 2 | 3 | #include "jemalloc/internal/jemalloc_preamble.h" 4 | #include "jemalloc/internal/jemalloc_internal_includes.h" 5 | 6 | #include "jemalloc/internal/mutex.h" 7 | #include "jemalloc/internal/mutex_pool.h" 8 | 9 | bool 10 | mutex_pool_init(mutex_pool_t *pool, const char *name, witness_rank_t rank) { 11 | for (int i = 0; i < MUTEX_POOL_SIZE; ++i) { 12 | if (malloc_mutex_init(&pool->mutexes[i], name, rank, 13 | malloc_mutex_address_ordered)) { 14 | return true; 15 | } 16 | } 17 | return false; 18 | } 19 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/src/prng.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_PRNG_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/src/ticker.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TICKER_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/include/test/jemalloc_test_defs.h.in: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_internal_defs.h" 2 | #include "jemalloc/internal/jemalloc_internal_decls.h" 3 | 4 | /* 5 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 6 | * dependencies are notoriously unportable in practice. 7 | */ 8 | #undef HAVE_SSE2 9 | #undef HAVE_ALTIVEC 10 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/include/test/mtx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mtx is a slightly simplified version of malloc_mutex. This code duplication 3 | * is unfortunate, but there are allocator bootstrapping considerations that 4 | * would leak into the test infrastructure if malloc_mutex were used directly 5 | * in tests. 6 | */ 7 | 8 | typedef struct { 9 | #ifdef _WIN32 10 | CRITICAL_SECTION lock; 11 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 12 | os_unfair_lock lock; 13 | #elif (defined(JEMALLOC_OSSPIN)) 14 | OSSpinLock lock; 15 | #else 16 | pthread_mutex_t lock; 17 | #endif 18 | } mtx_t; 19 | 20 | bool mtx_init(mtx_t *mtx); 21 | void mtx_fini(mtx_t *mtx); 22 | void mtx_lock(mtx_t *mtx); 23 | void mtx_unlock(mtx_t *mtx); 24 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/include/test/thd.h: -------------------------------------------------------------------------------- 1 | /* Abstraction layer for threading in tests. */ 2 | #ifdef _WIN32 3 | typedef HANDLE thd_t; 4 | #else 5 | typedef pthread_t thd_t; 6 | #endif 7 | 8 | void thd_create(thd_t *thd, void *(*proc)(void *), void *arg); 9 | void thd_join(thd_t thd, void **ret); 10 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/include/test/timer.h: -------------------------------------------------------------------------------- 1 | /* Simple timer, for use in benchmark reporting. */ 2 | 3 | typedef struct { 4 | nstime_t t0; 5 | nstime_t t1; 6 | } timedelta_t; 7 | 8 | void timer_start(timedelta_t *timer); 9 | void timer_stop(timedelta_t *timer); 10 | uint64_t timer_usec(const timedelta_t *timer); 11 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 12 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/integration/extent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/integration/mallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/integration/xallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/src/btalloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void * 4 | btalloc(size_t size, unsigned bits) { 5 | return btalloc_0(size, bits); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/src/mq.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | /* 4 | * Sleep for approximately ns nanoseconds. No lower *nor* upper bound on sleep 5 | * time is guaranteed. 6 | */ 7 | void 8 | mq_nanosleep(unsigned ns) { 9 | assert(ns <= 1000*1000*1000); 10 | 11 | #ifdef _WIN32 12 | Sleep(ns / 1000); 13 | #else 14 | { 15 | struct timespec timeout; 16 | 17 | if (ns < 1000*1000*1000) { 18 | timeout.tv_sec = 0; 19 | timeout.tv_nsec = ns; 20 | } else { 21 | timeout.tv_sec = 1; 22 | timeout.tv_nsec = 0; 23 | } 24 | nanosleep(&timeout, NULL); 25 | } 26 | #endif 27 | } 28 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/a0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_a0) { 4 | void *p; 5 | 6 | p = a0malloc(1); 7 | assert_ptr_not_null(p, "Unexpected a0malloc() error"); 8 | a0dalloc(p); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test_no_malloc_init( 15 | test_a0); 16 | } 17 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/arena_reset_prof.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | #define ARENA_RESET_PROF_C_ 3 | 4 | #include "arena_reset.c" 5 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/decay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="dirty_decay_ms:1000,muzzy_decay_ms:1000,lg_tcache_max:0" 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/div.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/div.h" 4 | 5 | TEST_BEGIN(test_div_exhaustive) { 6 | for (size_t divisor = 2; divisor < 1000 * 1000; ++divisor) { 7 | div_info_t div_info; 8 | div_init(&div_info, divisor); 9 | size_t max = 1000 * divisor; 10 | if (max < 1000 * 1000) { 11 | max = 1000 * 1000; 12 | } 13 | for (size_t dividend = 0; dividend < 1000 * divisor; 14 | dividend += divisor) { 15 | size_t quotient = div_compute( 16 | &div_info, dividend); 17 | assert_zu_eq(dividend, quotient * divisor, 18 | "With divisor = %zu, dividend = %zu, " 19 | "got quotient %zu", divisor, dividend, quotient); 20 | } 21 | } 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test_no_reentrancy( 28 | test_div_exhaustive); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/junk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:true" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/junk_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:alloc" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/junk_free.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:free" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Immediately purge to minimize fragmentation. 4 | export MALLOC_CONF="dirty_decay_ms:0,muzzy_decay_ms:0" 5 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_accum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_active.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_thread_active_init:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_gdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_idump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache:false" 4 | if [ "x${enable_prof}" = "x1" ] ; then 5 | export MALLOC_CONF="${MALLOC_CONF},prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0" 6 | fi 7 | 8 | 9 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_reset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_tctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/prof_thread_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/spin.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/spin.h" 4 | 5 | TEST_BEGIN(test_spin) { 6 | spin_t spinner = SPIN_INITIALIZER; 7 | 8 | for (unsigned i = 0; i < 100; i++) { 9 | spin_adaptive(&spinner); 10 | } 11 | } 12 | TEST_END 13 | 14 | int 15 | main(void) { 16 | return test( 17 | test_spin); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/jemalloc/test/unit/zero.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,junk:false,zero:true" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/linenoise/.gitignore: -------------------------------------------------------------------------------- 1 | linenoise_example 2 | *.dSYM 3 | history.txt 4 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/linenoise/Makefile: -------------------------------------------------------------------------------- 1 | STD= 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | linenoise.o: linenoise.h linenoise.c 13 | 14 | linenoise_example: linenoise.o example.o 15 | $(R_LD) -o $@ $^ 16 | 17 | .c.o: 18 | $(R_CC) -c $< 19 | 20 | clean: 21 | rm -f linenoise_example *.o 22 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/deps/lua/doc/cover.png -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/deps/lua/etc/lua.ico -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/src/fpconv.h: -------------------------------------------------------------------------------- 1 | /* Lua CJSON floating point conversion routines */ 2 | 3 | /* Buffer required to store the largest string representation of a double. 4 | * 5 | * Longest double printed with %.14g is 21 characters long: 6 | * -1.7976931348623e+308 */ 7 | # define FPCONV_G_FMT_BUFSIZE 32 8 | 9 | #ifdef USE_INTERNAL_FPCONV 10 | static inline void fpconv_init() 11 | { 12 | /* Do nothing - not required */ 13 | } 14 | #else 15 | extern void fpconv_init(); 16 | #endif 17 | 18 | extern int fpconv_g_fmt(char*, double, int); 19 | extern double fpconv_strtod(const char*, char**); 20 | 21 | /* vi:ai et sw=4 ts=4: 22 | */ 23 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/deps/lua/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b) /tmp/jemalloc.tar.bz2 6 | tar xvjf /tmp/jemalloc.tar.bz2 7 | rm -rf jemalloc 8 | mv jemalloc-${VER} jemalloc 9 | echo "Use git status, add all files and commit changes." 10 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | $TCLSH tests/test_helper.tcl "${@}" 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/runtest-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/cluster/run.tcl $* 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/runtest-moduleapi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | 15 | make -C tests/modules && \ 16 | $TCLSH tests/test_helper.tcl \ 17 | --single unit/moduleapi/commandfilter \ 18 | --single unit/moduleapi/fork \ 19 | --single unit/moduleapi/testrdb \ 20 | --single unit/moduleapi/infotest \ 21 | --single unit/moduleapi/propagate \ 22 | --single unit/moduleapi/hooks \ 23 | --single unit/moduleapi/misc \ 24 | --single unit/moduleapi/blockonkeys \ 25 | --single unit/moduleapi/scan \ 26 | --single unit/moduleapi/datatype \ 27 | --single unit/moduleapi/auth \ 28 | "${@}" 29 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/runtest-sentinel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/sentinel/run.tcl $* 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/.gitignore: -------------------------------------------------------------------------------- 1 | *.gcda 2 | *.gcno 3 | *.gcov 4 | redis.info 5 | lcov-html 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/crc64.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC64_H 2 | #define CRC64_H 3 | 4 | #include 5 | 6 | void crc64_init(void); 7 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); 8 | 9 | #ifdef REDIS_TEST 10 | int crc64Test(int argc, char *argv[]); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/geo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEO_H__ 2 | #define __GEO_H__ 3 | 4 | #include "server.h" 5 | 6 | /* Structures used inside geo.c in order to represent points and array of 7 | * points on the earth. */ 8 | typedef struct geoPoint { 9 | double longitude; 10 | double latitude; 11 | double dist; 12 | double score; 13 | char *member; 14 | } geoPoint; 15 | 16 | typedef struct geoArray { 17 | struct geoPoint *array; 18 | size_t buckets; 19 | size_t used; 20 | } geoArray; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/mkreleasehdr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1` 3 | GIT_DIRTY=`git diff --no-ext-diff 2> /dev/null | wc -l` 4 | BUILD_ID=`uname -n`"-"`date +%s` 5 | if [ -n "$SOURCE_DATE_EPOCH" ]; then 6 | BUILD_ID=$(date -u -d "@$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u +%s) 7 | fi 8 | test -f release.h || touch release.h 9 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \ 10 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already up-to-date 11 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h 12 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h 13 | echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h 14 | touch release.c # Force recompile of release.c 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.xo 3 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | #define SHA1_H 3 | /* ================ sha1.h ================ */ 4 | /* 5 | SHA-1 in C 6 | By Steve Reid 7 | 100% Public Domain 8 | */ 9 | 10 | typedef struct { 11 | uint32_t state[5]; 12 | uint32_t count[2]; 13 | unsigned char buffer[64]; 14 | } SHA1_CTX; 15 | 16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]); 17 | void SHA1Init(SHA1_CTX* context); 18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); 19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 20 | 21 | #ifdef REDIS_TEST 22 | int sha1Test(int argc, char **argv); 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/valgrind.sup: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | fun:lzf_compress 5 | } 6 | 7 | { 8 | 9 | Memcheck:Value4 10 | fun:lzf_compress 11 | } 12 | 13 | { 14 | 15 | Memcheck:Value8 16 | fun:lzf_compress 17 | } 18 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/src/version.h: -------------------------------------------------------------------------------- 1 | #define REDIS_VERSION "6.0.3" 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/assets/default.conf: -------------------------------------------------------------------------------- 1 | # Redis configuration for testing. 2 | 3 | always-show-logo yes 4 | notify-keyspace-events KEA 5 | daemonize no 6 | pidfile /var/run/redis.pid 7 | port 6379 8 | timeout 0 9 | bind 127.0.0.1 10 | loglevel verbose 11 | logfile '' 12 | databases 16 13 | latency-monitor-threshold 1 14 | 15 | save 900 1 16 | save 300 10 17 | save 60 10000 18 | 19 | rdbcompression yes 20 | dbfilename dump.rdb 21 | dir ./ 22 | 23 | slave-serve-stale-data yes 24 | appendonly no 25 | appendfsync everysec 26 | no-appendfsync-on-rewrite no 27 | activerehashing yes 28 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/assets/encodings.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/tests/assets/encodings.rdb -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/assets/hash-zipmap.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter02/redis-6.0.3/tests/assets/hash-zipmap.rdb -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/cluster/run.tcl: -------------------------------------------------------------------------------- 1 | # Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/cluster 6 | source cluster.tcl 7 | source ../instances.tcl 8 | source ../../support/cluster.tcl ; # Redis Cluster client. 9 | 10 | set ::instances_count 20 ; # How many instances we use at max. 11 | set ::tlsdir "../../tls" 12 | 13 | proc main {} { 14 | parse_options 15 | spawn_instance redis $::redis_base_port $::instances_count { 16 | "cluster-enabled yes" 17 | "appendonly yes" 18 | } 19 | run_tests 20 | cleanup 21 | end_tests 22 | } 23 | 24 | if {[catch main e]} { 25 | puts $::errorInfo 26 | if {$::pause_on_error} pause_on_error 27 | cleanup 28 | exit 1 29 | } 30 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/cluster/tests/helpers/onlydots.tcl: -------------------------------------------------------------------------------- 1 | # Read the standard input and only shows dots in the output, filtering out 2 | # all the other characters. Designed to avoid bufferization so that when 3 | # we get the output of redis-trib and want to show just the dots, we'll see 4 | # the dots as soon as redis-trib will output them. 5 | 6 | fconfigure stdin -buffering none 7 | 8 | while 1 { 9 | set c [read stdin 1] 10 | if {$c eq {}} { 11 | exit 0; # EOF 12 | } elseif {$c eq {.}} { 13 | puts -nonewline . 14 | flush stdout 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/cluster/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/helpers/bg_complex_data.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | set ::tlsdir "tests/tls" 5 | 6 | proc bg_complex_data {host port db ops tls} { 7 | set r [redis $host $port 0 $tls] 8 | $r select $db 9 | createComplexDataset $r $ops 10 | } 11 | 12 | bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] 13 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/helpers/gen_write_load.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | 3 | set ::tlsdir "tests/tls" 4 | 5 | proc gen_write_load {host port seconds tls} { 6 | set start_time [clock seconds] 7 | set r [redis $host $port 1 $tls] 8 | $r select 9 9 | while 1 { 10 | $r set [expr rand()] [expr rand()] 11 | if {[clock seconds]-$start_time > $seconds} { 12 | exit 0 13 | } 14 | } 15 | } 16 | 17 | gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 18 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/sentinel/run.tcl: -------------------------------------------------------------------------------- 1 | # Sentinel test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/sentinel 6 | source ../instances.tcl 7 | 8 | set ::instances_count 5 ; # How many instances we use at max. 9 | set ::tlsdir "../../tls" 10 | 11 | proc main {} { 12 | parse_options 13 | spawn_instance sentinel $::sentinel_base_port $::instances_count 14 | spawn_instance redis $::redis_base_port $::instances_count 15 | run_tests 16 | cleanup 17 | end_tests 18 | } 19 | 20 | if {[catch main e]} { 21 | puts $::errorInfo 22 | cleanup 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/sentinel/tests/03-runtime-reconf.tcl: -------------------------------------------------------------------------------- 1 | # Test runtime reconfiguration command SENTINEL SET. 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/sentinel/tests/04-slave-selection.tcl: -------------------------------------------------------------------------------- 1 | # Test slave selection algorithm. 2 | # 3 | # This unit should test: 4 | # 1) That when there are no suitable slaves no failover is performed. 5 | # 2) That among the available slaves, the one with better offset is picked. 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/sentinel/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/support/cli.tcl: -------------------------------------------------------------------------------- 1 | proc rediscli_tls_config {testsdir} { 2 | set tlsdir [file join $testsdir tls] 3 | set cert [file join $tlsdir redis.crt] 4 | set key [file join $tlsdir redis.key] 5 | set cacert [file join $tlsdir ca.crt] 6 | 7 | if {$::tls} { 8 | return [list --tls --cert $cert --key $key --cacert $cacert] 9 | } else { 10 | return {} 11 | } 12 | } 13 | 14 | proc rediscli {port {opts {}}} { 15 | set cmd [list src/redis-cli -p $port] 16 | lappend cmd {*}[rediscli_tls_config "tests"] 17 | lappend cmd {*}$opts 18 | return $cmd 19 | } 20 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/support/tmpfile.tcl: -------------------------------------------------------------------------------- 1 | set ::tmpcounter 0 2 | set ::tmproot "./tests/tmp" 3 | file mkdir $::tmproot 4 | 5 | # returns a dirname unique to this process to write to 6 | proc tmpdir {basename} { 7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]] 8 | file mkdir $dir 9 | set _ $dir 10 | } 11 | 12 | # return a filename unique to this process to write to 13 | proc tmpfile {basename} { 14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter] 15 | } 16 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/unit/auth.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"auth"}} { 2 | test {AUTH fails if there is no password configured server side} { 3 | catch {r auth foo} err 4 | set _ $err 5 | } {ERR*any password*} 6 | } 7 | 8 | start_server {tags {"auth"} overrides {requirepass foobar}} { 9 | test {AUTH fails when a wrong password is given} { 10 | catch {r auth wrong!} err 11 | set _ $err 12 | } {WRONGPASS*} 13 | 14 | test {Arbitrary command gives an error when AUTH is required} { 15 | catch {r set foo bar} err 16 | set _ $err 17 | } {NOAUTH*} 18 | 19 | test {AUTH succeeds when the right password is given} { 20 | r auth foobar 21 | } {OK} 22 | 23 | test {Once AUTH succeeded we can actually send commands to the server} { 24 | r set foo 100 25 | r incr foo 26 | } {101} 27 | } 28 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/unit/limits.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"limits"} overrides {maxclients 10}} { 2 | if {$::tls} { 3 | set expected_code "*I/O error*" 4 | } else { 5 | set expected_code "*ERR max*reached*" 6 | } 7 | test {Check if maxclients works refusing connections} { 8 | set c 0 9 | catch { 10 | while {$c < 50} { 11 | incr c 12 | set rd [redis_deferring_client] 13 | $rd ping 14 | $rd read 15 | after 100 16 | } 17 | } e 18 | assert {$c > 8 && $c <= 10} 19 | set e 20 | } $expected_code 21 | } 22 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/unit/printver.tcl: -------------------------------------------------------------------------------- 1 | start_server {} { 2 | set i [r info] 3 | regexp {redis_version:(.*?)\r\n} $i - version 4 | regexp {redis_git_sha1:(.*?)\r\n} $i - sha1 5 | puts "Testing Redis version $version ($sha1)" 6 | } 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/tests/unit/type/list-common.tcl: -------------------------------------------------------------------------------- 1 | # We need a value larger than list-max-ziplist-value to make sure 2 | # the list has the right encoding when it is swapped in again. 3 | array set largevalue {} 4 | set largevalue(ziplist) "hello" 5 | set largevalue(linkedlist) [string repeat "hello" 4] 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/build-static-symbols.tcl: -------------------------------------------------------------------------------- 1 | # Build a symbol table for static symbols of redis.c 2 | # Useful to get stack traces on segfault without a debugger. See redis.c 3 | # for more information. 4 | # 5 | # Copyright(C) 2009 Salvatore Sanfilippo, under the BSD license. 6 | 7 | set fd [open redis.c] 8 | set symlist {} 9 | while {[gets $fd line] != -1} { 10 | if {[regexp {^static +[A-z0-9]+[ *]+([A-z0-9]*)\(} $line - sym]} { 11 | lappend symlist $sym 12 | } 13 | } 14 | set symlist [lsort -unique $symlist] 15 | puts "static struct redisFunctionSym symsTable\[\] = {" 16 | foreach sym $symlist { 17 | puts "{\"$sym\",(unsigned long)$sym}," 18 | } 19 | puts "{NULL,0}" 20 | puts "};" 21 | 22 | close $fd 23 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/create-cluster/.gitignore: -------------------------------------------------------------------------------- 1 | config.sh 2 | *.rdb 3 | *.aof 4 | *.conf 5 | *.log 6 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/gen-test-certs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p tests/tls 3 | openssl genrsa -out tests/tls/ca.key 4096 4 | openssl req \ 5 | -x509 -new -nodes -sha256 \ 6 | -key tests/tls/ca.key \ 7 | -days 3650 \ 8 | -subj '/O=Redis Test/CN=Certificate Authority' \ 9 | -out tests/tls/ca.crt 10 | openssl genrsa -out tests/tls/redis.key 2048 11 | openssl req \ 12 | -new -sha256 \ 13 | -key tests/tls/redis.key \ 14 | -subj '/O=Redis Test/CN=Server' | \ 15 | openssl x509 \ 16 | -req -sha256 \ 17 | -CA tests/tls/ca.crt \ 18 | -CAkey tests/tls/ca.key \ 19 | -CAserial tests/tls/ca.txt \ 20 | -CAcreateserial \ 21 | -days 365 \ 22 | -out tests/tls/redis.crt 23 | openssl dhparam -out tests/tls/redis.dh 2048 24 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/graphs/commits-over-time/README.md: -------------------------------------------------------------------------------- 1 | This Tcl script is what I used in order to generate the graph you 2 | can find at http://antirez.com/news/98. It's really quick & dirty, more 3 | a trow away program than anything else, but probably could be reused or 4 | modified in the future in order to visualize other similar data or an 5 | updated version of the same data. 6 | 7 | The usage is trivial: 8 | 9 | ./genhtml.tcl > output.html 10 | 11 | The generated HTML is quite broken but good enough to grab a screenshot 12 | from the browser. Feel free to improve it if you got time / interest. 13 | 14 | Note that the code filtering the tags, and the hardcoded branch name, does 15 | not make the script, as it is, able to analyze a different repository. 16 | However the changes needed are trivial. 17 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/hashtable/README: -------------------------------------------------------------------------------- 1 | Hash table implementation related utilities. 2 | 3 | rehashing.c 4 | --- 5 | 6 | Visually show buckets in the two hash tables between rehashings. Also stress 7 | test getRandomKeys() implementation, that may actually disappear from 8 | Redis soon, however visualization some code is reusable in new bugs 9 | investigation. 10 | 11 | Compile with: 12 | 13 | cc -I ../../src/ rehashing.c ../../src/zmalloc.c ../../src/dict.c -o rehashing_test 14 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/hyperloglog/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/hyperloglog/hll-err.rb: -------------------------------------------------------------------------------- 1 | # hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo 2 | # BSD license, See the COPYING file for more information. 3 | # 4 | # Check error of HyperLogLog Redis implementation for different set sizes. 5 | 6 | require 'rubygems' 7 | require 'redis' 8 | require 'digest/sha1' 9 | 10 | r = Redis.new 11 | r.del('hll') 12 | i = 0 13 | while true do 14 | 100.times { 15 | elements = [] 16 | 1000.times { 17 | ele = Digest::SHA1.hexdigest(i.to_s) 18 | elements << ele 19 | i += 1 20 | } 21 | r.pfadd('hll',elements) 22 | } 23 | approx = r.pfcount('hll') 24 | abs_err = (approx-i).abs 25 | rel_err = 100.to_f*abs_err/i 26 | puts "#{i} vs #{approx}: #{rel_err}%" 27 | end 28 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/lru/README: -------------------------------------------------------------------------------- 1 | The test-lru.rb program can be used in order to check the behavior of the 2 | Redis approximated LRU algorithm against the theoretical output of true 3 | LRU algorithm. 4 | 5 | In order to use the program you need to recompile Redis setting the define 6 | REDIS_LRU_CLOCK_RESOLUTION to 1, by editing the file server.h. 7 | This allows to execute the program in a fast way since the 1 ms resolution 8 | is enough for all the objects to have a different enough time stamp during 9 | the test. 10 | 11 | The program is executed like this: 12 | 13 | ruby test-lru.rb /tmp/lru.html 14 | 15 | You can optionally specify a number of times to run, so that the program 16 | will output averages of different runs, by adding an additional argument. 17 | For instance in order to run the test 10 times use: 18 | 19 | ruby test-lru.rb /tmp/lru.html 10 20 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/releasetools/01_create_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ./mkrelease.sh " 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar" 10 | echo "Generating /tmp/${TARNAME}" 11 | cd ~/hack/redis 12 | git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1 13 | echo "Gizipping the archive" 14 | rm -f /tmp/$TARNAME.gz 15 | gzip -9 /tmp/$TARNAME 16 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/releasetools/02_upload_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Uploading..." 3 | scp /tmp/redis-${1}.tar.gz antirez@antirez.com:/var/virtual/download.redis.io/httpdocs/releases/ 4 | echo "Updating web site... (press any key if it is a stable release, or Ctrl+C)" 5 | read x 6 | ssh antirez@antirez.com "cd /var/virtual/download.redis.io/httpdocs; ./update.sh ${1}" 7 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/releasetools/03_test_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ${0} " 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar.gz" 10 | DOWNLOADURL="http://download.redis.io/releases/${TARNAME}" 11 | 12 | ssh antirez@metal "export TERM=xterm; 13 | cd /tmp; 14 | rm -rf test_release_tmp_dir; 15 | cd test_release_tmp_dir; 16 | rm -f $TARNAME; 17 | rm -rf redis-${TAG}; 18 | wget $DOWNLOADURL; 19 | tar xvzf $TARNAME; 20 | cd redis-${TAG}; 21 | make; 22 | ./runtest; 23 | ./runtest-sentinel; 24 | if [ -x runtest-cluster ]; then 25 | ./runtest-cluster; 26 | fi" 27 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/releasetools/04_release_hash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SHA=$(curl -s http://download.redis.io/releases/redis-${1}.tar.gz | shasum -a 256 | cut -f 1 -d' ') 3 | ENTRY="hash redis-${1}.tar.gz sha256 $SHA http://download.redis.io/releases/redis-${1}.tar.gz" 4 | echo $ENTRY >> ~/hack/redis-hashes/README 5 | vi ~/hack/redis-hashes/README 6 | echo "Press any key to commit, Ctrl-C to abort)." 7 | read yes 8 | (cd ~/hack/redis-hashes; git commit -a -m "${1} hash."; git push) 9 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/srandmember/README.md: -------------------------------------------------------------------------------- 1 | The utilities in this directory plot the distribution of SRANDMEMBER to 2 | evaluate how fair it is. 3 | 4 | See http://theshfl.com/redis_sets for more information on the topic that lead 5 | to such investigation fix. 6 | 7 | showdist.rb -- shows the distribution of the frequency elements are returned. 8 | The x axis is the number of times elements were returned, and 9 | the y axis is how many elements were returned with such 10 | frequency. 11 | 12 | showfreq.rb -- shows the frequency each element was returned. 13 | The x axis is the element number. 14 | The y axis is the times it was returned. 15 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/srandmember/showdist.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 100.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Convert into frequency distribution 21 | dist = {} 22 | freq.each{|item,count| 23 | dist[count] = 0 if dist[count] == nil 24 | dist[count] += 1 25 | } 26 | 27 | min = dist.keys.min 28 | max = dist.keys.max 29 | (min..max).each{|x| 30 | count = dist[x] 31 | count = 0 if count == nil 32 | puts "#{x} -> #{"*"*count}" 33 | } 34 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/srandmember/showfreq.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 500.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Print the frequency each element was yeld to process it with gnuplot 21 | freq.each{|item,count| 22 | puts "#{item} #{count}" 23 | } 24 | -------------------------------------------------------------------------------- /Chapter02/redis-6.0.3/utils/whatisdoing.sh: -------------------------------------------------------------------------------- 1 | # This script is from http://poormansprofiler.org/ 2 | # 3 | # NOTE: Instead of using this script, you should use the Redis 4 | # Software Watchdog, which provides a similar functionality but in 5 | # a more reliable / easy to use way. 6 | # 7 | # Check http://redis.io/topics/latency for more information. 8 | 9 | #!/bin/bash 10 | nsamples=1 11 | sleeptime=0 12 | pid=$(ps auxww | grep '[r]edis-server' | awk '{print $2}') 13 | 14 | for x in $(seq 1 $nsamples) 15 | do 16 | gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid 17 | sleep $sleeptime 18 | done | \ 19 | awk ' 20 | BEGIN { s = ""; } 21 | /Thread/ { print s; s = ""; } 22 | /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } } 23 | END { print s }' | \ 24 | sort | uniq -c | sort -r -n -k 1,1 25 | -------------------------------------------------------------------------------- /Chapter03/code/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/.DS_Store -------------------------------------------------------------------------------- /Chapter03/code/SharedMutex.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/SharedMutex.cpp -------------------------------------------------------------------------------- /Chapter03/code/SharedMutex.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/SharedMutex.h -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/SingleInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/SingleInstance.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/SingleInstance/SingleInstance.ico -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/SingleInstance.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/SingleInstance/SingleInstance.rc -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/SingleInstance/small.ico -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SingleInstance.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | // C RunTime Header Files 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // TODO: reference additional headers your program requires here 22 | -------------------------------------------------------------------------------- /Chapter03/code/SingleInstance/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter03/code/TaskPool.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/TaskPool.cpp -------------------------------------------------------------------------------- /Chapter03/code/TaskPool.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/TaskPool.h -------------------------------------------------------------------------------- /Chapter03/code/TestFiber.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/TestFiber.cpp -------------------------------------------------------------------------------- /Chapter03/code/TestWindowsConditionVariable/TestWindowsConditionVariable.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/TestWindowsConditionVariable/TestWindowsConditionVariable.cpp -------------------------------------------------------------------------------- /Chapter03/code/c11mutex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | // protected by g_num_mutex 7 | int g_num = 0; 8 | std::mutex g_num_mutex; 9 | 10 | void slow_increment(int id) 11 | { 12 | for (int i = 0; i < 3; ++i) { 13 | g_num_mutex.lock(); 14 | ++g_num; 15 | std::cout << id << " => " << g_num << std::endl; 16 | g_num_mutex.unlock(); 17 | 18 | //sleep for 1 second 19 | std::this_thread::sleep_for(std::chrono::seconds(1)); 20 | } 21 | } 22 | 23 | int main() 24 | { 25 | std::thread t1(slow_increment, 0); 26 | std::thread t2(slow_increment, 1); 27 | t1.join(); 28 | t2.join(); 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Chapter03/code/c11threadlocal.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | thread_local int g_mydata = 1; 6 | 7 | void thread_func1() 8 | { 9 | while (true) 10 | { 11 | ++g_mydata; 12 | } 13 | } 14 | 15 | void thread_func2() 16 | { 17 | while (true) 18 | { 19 | std::cout << "g_mydata = " << g_mydata << ", ThreadID = " << std::this_thread::get_id() << std::endl; 20 | std::this_thread::sleep_for(std::chrono::seconds(1)); 21 | } 22 | } 23 | 24 | int main() 25 | { 26 | std::thread t1(thread_func1); 27 | std::thread t2(thread_func2); 28 | 29 | t1.join(); 30 | t2.join(); 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Chapter03/code/insecurecrtfunction.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter03/code/insecurecrtfunction.cpp -------------------------------------------------------------------------------- /Chapter03/code/linuxtid.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void* thread_proc(void* arg) 7 | { 8 | pthread_t* tid1 = (pthread_t*)arg; 9 | int tid2 = syscall(SYS_gettid); 10 | pthread_t tid3 = pthread_self(); 11 | 12 | while(true) 13 | { 14 | printf("tid1: %ld, tid2: %ld, tid3: %ld\n", *tid1, tid2, tid3); 15 | sleep(1); 16 | } 17 | 18 | } 19 | 20 | int main() 21 | { 22 | pthread_t tid; 23 | pthread_create(&tid, NULL, thread_proc, &tid); 24 | 25 | pthread_join(tid, NULL); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Chapter03/code/linuxtls2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | //线程局部存储key 6 | __thread int g_mydata = 99; 7 | 8 | void* thread_function1(void* args) 9 | { 10 | while (true) 11 | { 12 | g_mydata ++; 13 | } 14 | 15 | return NULL; 16 | } 17 | 18 | void* thread_function2(void* args) 19 | { 20 | while (true) 21 | { 22 | std::cout << "g_mydata = " << g_mydata << ", ThreadID: " << pthread_self() << std::endl; 23 | sleep(1); 24 | } 25 | 26 | return NULL; 27 | } 28 | 29 | int main() 30 | { 31 | pthread_t threadIDs[2]; 32 | pthread_create(&threadIDs[0], NULL, thread_function1, NULL); 33 | pthread_create(&threadIDs[1], NULL, thread_function2, NULL); 34 | 35 | for(int i = 0; i < 2; ++i) 36 | { 37 | pthread_join(threadIDs[i], NULL); 38 | } 39 | 40 | return 0; 41 | } -------------------------------------------------------------------------------- /Chapter03/code/makesurethread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::mutex mymutex; 7 | std::condition_variable mycv; 8 | bool success = false; 9 | 10 | void thread_func() 11 | { 12 | { 13 | std::unique_lock lock(mymutex); 14 | success = true; 15 | mycv.notify_all(); 16 | } 17 | 18 | //实际的线程执行的工作代码放在下面 19 | //这里为了模拟方便,简单地写个死循环 20 | while (true) 21 | { 22 | 23 | } 24 | } 25 | 26 | int main() 27 | { 28 | std::thread t(thread_func); 29 | 30 | //使用花括号减小锁的粒度 31 | { 32 | std::unique_lock lock(mymutex); 33 | while (!success) 34 | { 35 | mycv.wait(lock); 36 | } 37 | } 38 | 39 | std::cout << "start thread successfully." << std::endl; 40 | 41 | t.join(); 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /Chapter03/code/taskpoolmain.cpp: -------------------------------------------------------------------------------- 1 | #include "TaskPool.h" 2 | #include 3 | 4 | int main() 5 | { 6 | TaskPool threadPool; 7 | threadPool.init(); 8 | 9 | Task* task = NULL; 10 | for (int i = 0; i < 10; ++i) 11 | { 12 | task = new Task(); 13 | threadPool.addTask(task); 14 | } 15 | 16 | std::this_thread::sleep_for(std::chrono::seconds(5)); 17 | 18 | threadPool.stop(); 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /Chapter03/code/test_destroy_locked_mutex.cpp: -------------------------------------------------------------------------------- 1 | //test_destroy_locked_mutex.cpp 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | pthread_mutex_t mymutex; 9 | pthread_mutex_init(&mymutex, NULL); 10 | int ret = pthread_mutex_lock(&mymutex); 11 | 12 | //尝试对被锁定的mutex对象进行销毁 13 | ret = pthread_mutex_destroy(&mymutex); 14 | if (ret != 0) 15 | { 16 | if (ret == EBUSY) 17 | printf("EBUSY\n"); 18 | printf("Failed to destroy mutex.\n"); 19 | } 20 | 21 | ret = pthread_mutex_unlock(&mymutex); 22 | //尝试对已经解锁的mutex对象进行销毁 23 | ret = pthread_mutex_destroy(&mymutex); 24 | if (ret == 0) 25 | printf("Succeeded to destroy mutex.\n"); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/IOCPServerApp.h: -------------------------------------------------------------------------------- 1 | // IOCPServerApp.h : PROJECT_NAME 应用程序的主头文件 2 | // 3 | 4 | #pragma once 5 | 6 | #ifndef __AFXWIN_H__ 7 | #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件" 8 | #endif 9 | 10 | //#include "resource.h" // 主符号 11 | 12 | 13 | // CIOCPServerApp: 14 | // 有关此类的实现,请参阅 CIOCPServerApp.cpp 15 | // 16 | class CIOCPServerApp : public CWinApp 17 | { 18 | public: 19 | CIOCPServerApp(); 20 | 21 | // 重写 22 | public: 23 | virtual BOOL InitInstance(); 24 | 25 | // 实现 26 | 27 | DECLARE_MESSAGE_MAP() 28 | }; 29 | 30 | extern CIOCPServerApp theApp; -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/IOCPServerDemo.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/IOCPServerDemo.rc -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/XPStyle.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | 17 | 18 | 19 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/res/IOCPServerDemo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/res/IOCPServerDemo.ico -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/res/IOCPServerDemo.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/res/IOCPServerDemo.rc2 -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/res/vssver2.scc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/res/vssver2.scc -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/stdafx.cpp -------------------------------------------------------------------------------- /Chapter04/code/IOCPServerDemo/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/IOCPServerDemo/stdafx.h -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.cpp -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.ico -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/WSAAsyncSelect/WSAAsyncSelect.rc -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/WSAAsyncSelect/small.ico -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // WSAAsyncSelect.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 11 | // Windows Header Files: 12 | #include 13 | 14 | // C RunTime Header Files 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | // TODO: reference additional headers your program requires here 22 | -------------------------------------------------------------------------------- /Chapter04/code/WSAAsyncSelect/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter04/code/WSAEventSelect/WSAEventSelect.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/WSAEventSelect/WSAEventSelect.cpp -------------------------------------------------------------------------------- /Chapter04/code/WSAEventSelect/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // WSAEventSelect.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter04/code/WSAEventSelect/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /Chapter04/code/WSAEventSelect/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter04/code/blocking_server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/blocking_server.cpp -------------------------------------------------------------------------------- /Chapter04/code/epoll_server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/epoll_server.cpp -------------------------------------------------------------------------------- /Chapter04/code/epoll_server_with_oneshot.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/epoll_server_with_oneshot.cpp -------------------------------------------------------------------------------- /Chapter04/code/linux_nonblocking_connect_poll.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/linux_nonblocking_connect_poll.cpp -------------------------------------------------------------------------------- /Chapter04/code/server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/server.cpp -------------------------------------------------------------------------------- /Chapter04/code/server2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter04/code/server2.cpp -------------------------------------------------------------------------------- /Chapter06/code/ProtocolStream.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/ProtocolStream.cpp -------------------------------------------------------------------------------- /Chapter06/code/ProtocolStream.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/ProtocolStream.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Base64Util.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/Base64Util.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Base64Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Base64Util final 6 | { 7 | private: 8 | Base64Util() = delete; 9 | ~Base64Util() = delete; 10 | Base64Util(const Base64Util& rhs) = delete; 11 | Base64Util& operator=(const Base64Util& rhs) = delete; 12 | 13 | public: 14 | static int encode(char* pDest, const char* pSource, int lenSource, char chMask, int maxDest); 15 | static int decode(char* pDest, const char* pSource, int lenSource, char chMask, int maxDest); 16 | static void decode(const char* pData, int nDataByte, std::string& strDecode); 17 | 18 | static bool check(char* lpString); 19 | }; 20 | -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/EncodeUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/EncodeUtil.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/EncodeUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/EncodeUtil.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/MailHelper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/MailHelper.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/MailHelper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/MailHelper.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/MailThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/MailThread.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/MailThread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/MailThread.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Platform.cpp: -------------------------------------------------------------------------------- 1 | #include "Platform.h" 2 | 3 | #ifdef WIN32 4 | 5 | NetworkInitializer::NetworkInitializer() 6 | { 7 | WORD wVersionRequested = MAKEWORD(2, 2); 8 | WSADATA wsaData; 9 | ::WSAStartup(wVersionRequested, &wsaData); 10 | } 11 | 12 | NetworkInitializer::~NetworkInitializer() 13 | { 14 | ::WSACleanup(); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/Platform.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Pop3Socket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/Pop3Socket.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/Pop3Socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/Pop3Socket.h -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/main.cpp -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/self.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/self.jpg -------------------------------------------------------------------------------- /Chapter06/code/RecvMail/test.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/RecvMail/test.docx -------------------------------------------------------------------------------- /Chapter06/code/SendMail/Base64Util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Base64Util final 4 | { 5 | private: 6 | Base64Util() = delete; 7 | ~Base64Util() = delete; 8 | Base64Util(const Base64Util& rhs) = delete; 9 | Base64Util& operator=(const Base64Util& rhs) = delete; 10 | 11 | public: 12 | static int encode(char* pDest, const char* pSource, int lenSource, char chMask, int maxDest); 13 | static int decode(char* pDest, const char* pSource, int lenSource, char chMask, int maxDest); 14 | static bool check(char* lpString); 15 | }; 16 | -------------------------------------------------------------------------------- /Chapter06/code/SendMail/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | project (SEND_MAIL_DEMO) 4 | 5 | 6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -g -Wall -O0 -Wno-unused-variable -pthread") 7 | 8 | set(srcs 9 | Base64Util.cpp 10 | MailMonitor.cpp 11 | Platform.cpp 12 | SmtpSocket.cpp 13 | main.cpp 14 | ) 15 | 16 | add_executable(alertmailsystem ${srcs}) 17 | TARGET_LINK_LIBRARIES(alertmailsystem) 18 | -------------------------------------------------------------------------------- /Chapter06/code/SendMail/MailMonitor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/SendMail/MailMonitor.h -------------------------------------------------------------------------------- /Chapter06/code/SendMail/Platform.cpp: -------------------------------------------------------------------------------- 1 | #include "Platform.h" 2 | 3 | #ifdef WIN32 4 | 5 | NetworkInitializer::NetworkInitializer() 6 | { 7 | WORD wVersionRequested = MAKEWORD(2, 2); 8 | WSADATA wsaData; 9 | ::WSAStartup(wVersionRequested, &wsaData); 10 | } 11 | 12 | NetworkInitializer::~NetworkInitializer() 13 | { 14 | ::WSACleanup(); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /Chapter06/code/SendMail/Platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/SendMail/Platform.h -------------------------------------------------------------------------------- /Chapter06/code/SendMail/SmtpSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/SendMail/SmtpSocket.cpp -------------------------------------------------------------------------------- /Chapter06/code/SendMail/SmtpSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/SendMail/SmtpSocket.h -------------------------------------------------------------------------------- /Chapter06/code/SendMail/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/SendMail/main.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/CMakeLists.txt -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/appsrc/BusinessSession.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/appsrc/BusinessSession.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/appsrc/BusinessSession.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/appsrc/BusinessSession.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/appsrc/main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/appsrc/main.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/AsyncLog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/base/AsyncLog.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/AsyncLog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/base/AsyncLog.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/ConfigFileReader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/base/ConfigFileReader.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/ConfigFileReader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/base/ConfigFileReader.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/Platform.cpp: -------------------------------------------------------------------------------- 1 | #include "Platform.h" 2 | 3 | #ifdef WIN32 4 | 5 | NetworkInitializer::NetworkInitializer() 6 | { 7 | WORD wVersionRequested = MAKEWORD(2, 2); 8 | WSADATA wsaData; 9 | ::WSAStartup(wVersionRequested, &wsaData); 10 | } 11 | 12 | NetworkInitializer::~NetworkInitializer() 13 | { 14 | ::WSACleanup(); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/Platform.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/base/Platform.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/RAIIWrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef __RAII_WRAPPER_H__ 2 | #define __RAII_WRAPPER_H__ 3 | 4 | template 5 | class RAIIWrapper 6 | { 7 | public: 8 | RAIIWrapper(T* p) :ptr(p) {} 9 | 10 | virtual ~RAIIWrapper() 11 | { 12 | if (ptr != NULL) 13 | { 14 | delete ptr; 15 | ptr = NULL; 16 | } 17 | } 18 | private: 19 | T* ptr; 20 | }; 21 | 22 | #endif //!__RAII_WRAPPER_H__ 23 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/base/Singleton.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | class Singleton 5 | { 6 | public: 7 | static T& Instance() 8 | { 9 | //pthread_once(&ponce_, &Singleton::init); 10 | if (nullptr == value_) 11 | { 12 | value_ = new T(); 13 | } 14 | return *value_; 15 | } 16 | 17 | private: 18 | Singleton(); 19 | ~Singleton(); 20 | 21 | Singleton(const Singleton&); 22 | Singleton& operator=(const Singleton&); 23 | 24 | static void init() 25 | { 26 | value_ = new T(); 27 | //::atexit(destroy); 28 | } 29 | 30 | static void destroy() 31 | { 32 | delete value_; 33 | } 34 | 35 | private: 36 | //static pthread_once_t ponce_; 37 | static T* value_; 38 | }; 39 | 40 | //template 41 | //pthread_once_t Singleton::ponce_ = PTHREAD_ONCE_INIT; 42 | 43 | template 44 | T* Singleton::value_ = nullptr; -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Acceptor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Acceptor.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Acceptor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Acceptor.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Buffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Buffer.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Buffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Buffer.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Channel.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Channel.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Channel.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Channel.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Connector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Connector.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/EventLoop.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/EventLoop.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/EventLoop.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/EventLoop.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/EventLoopThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/EventLoopThread.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/InetAddress.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/InetAddress.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/PollPoller.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/PollPoller.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Poller.cpp: -------------------------------------------------------------------------------- 1 | #include "Poller.h" 2 | #include "Channel.h" 3 | 4 | using namespace net; 5 | 6 | Poller::Poller() 7 | { 8 | } 9 | 10 | Poller::~Poller() 11 | { 12 | } 13 | 14 | //bool Poller::hasChannel(Channel* channel) const 15 | //{ 16 | // //assertInLoopThread(); 17 | // //ChannelMap::const_iterator it = channels_.find(channel->fd()); 18 | // //return it != channels_.end() && it->second == channel; 19 | // 20 | // return false; 21 | //} -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Poller.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "../base/Timestamp.h" 5 | 6 | namespace net 7 | { 8 | class Channel; 9 | 10 | class Poller 11 | { 12 | public: 13 | Poller(); 14 | ~Poller(); 15 | 16 | public: 17 | typedef std::vector ChannelList; 18 | 19 | virtual Timestamp poll(int timeoutMs, ChannelList* activeChannels) = 0; 20 | virtual bool updateChannel(Channel* channel) = 0; 21 | virtual void removeChannel(Channel* channel) = 0; 22 | 23 | virtual bool hasChannel(Channel* channel) const = 0; 24 | }; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/ProtocolStream.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/ProtocolStream.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/ProtocolStream.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/ProtocolStream.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/SelectPoller.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/SelectPoller.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Sockets.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Sockets.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Sockets.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Sockets.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TcpConnection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TcpConnection.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TcpConnection.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TcpConnection.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TcpServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TcpServer.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TcpServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TcpServer.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | 3 | using namespace net; 4 | 5 | std::atomic Timer::s_numCreated_; 6 | 7 | //void Timer::restart(Timestamp now) 8 | //{ 9 | // if (repeat_) 10 | // { 11 | // expiration_ = addTime(now, interval_); 12 | // } 13 | // else 14 | // { 15 | // expiration_ = Timestamp::invalid(); 16 | // } 17 | //} 18 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/Timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/Timer.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TimerId.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace net 4 | { 5 | class Timer; 6 | 7 | /// 8 | /// An opaque identifier, for canceling Timer. 9 | /// 10 | class TimerId 11 | { 12 | public: 13 | TimerId(): timer_(NULL), sequence_(0) 14 | { 15 | } 16 | 17 | TimerId(Timer* timer, int64_t seq) : timer_(timer), sequence_(seq) 18 | { 19 | } 20 | 21 | Timer* getTimer() 22 | { 23 | return timer_; 24 | } 25 | 26 | // default copy-ctor, dtor and assignment are okay 27 | 28 | friend class TimerQueue; 29 | 30 | private: 31 | Timer* timer_; 32 | int64_t sequence_; 33 | }; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TimerQueue.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TimerQueue.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/net/TimerQueue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/net/TimerQueue.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/DaemonRun.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/DaemonRun.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/DaemonRun.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/DaemonRun.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/StringUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/StringUtil.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/StringUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/StringUtil.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/UUIDGenerator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/UUIDGenerator.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/utils/UUIDGenerator.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/utils/UUIDGenerator.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketServer.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketServer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketServer.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketSession.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketSession.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketSession.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/websocketsrc/MyWebSocketSession.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/zlib1.2.11/ZlibUtil.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/zlib1.2.11/ZlibUtil.cpp -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/zlib1.2.11/ZlibUtil.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/zlib1.2.11/ZlibUtil.h -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/zlib1.2.11/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/zlib1.2.11/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /Chapter06/code/WebSocketServer/zlib1.2.11/zlibdemo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/WebSocketServer/zlib1.2.11/zlibdemo.c -------------------------------------------------------------------------------- /Chapter06/code/curl/libcurl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/curl/libcurl.dll -------------------------------------------------------------------------------- /Chapter06/code/curl/libcurl.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/curl/libcurl.lib -------------------------------------------------------------------------------- /Chapter06/code/curl/libcurl.so.4.5.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter06/code/curl/libcurl.so.4.5.0 -------------------------------------------------------------------------------- /Chapter07/codes/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/codes/.DS_Store -------------------------------------------------------------------------------- /Chapter07/codes/timerV1/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include 3 | 4 | std::atomic Timer::s_initialId = 0; 5 | 6 | Timer::Timer(int32_t repeatedTimes, int64_t interval, const TimerCallback& timerCallback) 7 | { 8 | m_repeatedTimes = repeatedTimes; 9 | m_interval = interval; 10 | 11 | //当前时间加上触发间隔得到下一次的过期时间 12 | m_expiredTime = (int64_t)time(nullptr) + interval; 13 | 14 | m_callback = timerCallback; 15 | 16 | //生成一个唯一的id 17 | ++s_initialId; 18 | m_id = s_initialId; 19 | } 20 | 21 | bool Timer::isExpired() 22 | { 23 | int64_t now = time(nullptr); 24 | return now >= m_expiredTime; 25 | } 26 | 27 | void Timer::run() 28 | { 29 | m_callback(); 30 | 31 | if (m_repeatedTimes >= 1) 32 | { 33 | --m_repeatedTimes; 34 | } 35 | 36 | m_expiredTime += m_interval; 37 | } -------------------------------------------------------------------------------- /Chapter07/codes/timerV2/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include 3 | 4 | std::atomic Timer::s_initialId = 0; 5 | 6 | Timer::Timer(int32_t repeatedTimes, int64_t interval, const TimerCallback& timerCallback) 7 | { 8 | m_repeatedTimes = repeatedTimes; 9 | m_interval = interval; 10 | 11 | //当前时间加上触发间隔得到下一次的过期时间 12 | m_expiredTime = (int64_t)time(nullptr) + interval; 13 | 14 | m_callback = timerCallback; 15 | 16 | //生成一个唯一的id 17 | ++s_initialId; 18 | m_id = s_initialId; 19 | } 20 | 21 | bool Timer::isExpired() 22 | { 23 | int64_t now = time(nullptr); 24 | return now >= m_expiredTime; 25 | } 26 | 27 | void Timer::run() 28 | { 29 | m_callback(); 30 | 31 | if (m_repeatedTimes >= 1) 32 | { 33 | --m_repeatedTimes; 34 | } 35 | 36 | m_expiredTime += m_interval; 37 | } -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test-ubuntu-latest: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - name: make 11 | run: make 12 | - name: test 13 | run: | 14 | sudo apt-get install tcl8.5 15 | ./runtest --verbose 16 | - name: module api test 17 | run: ./runtest-moduleapi --verbose 18 | 19 | build-ubuntu-old: 20 | runs-on: ubuntu-16.04 21 | steps: 22 | - uses: actions/checkout@v1 23 | - name: make 24 | run: make 25 | 26 | build-macos-latest: 27 | runs-on: macos-latest 28 | steps: 29 | - uses: actions/checkout@v1 30 | - name: make 31 | run: make 32 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.o 3 | *.xo 4 | *.so 5 | *.d 6 | *.log 7 | dump.rdb 8 | redis-benchmark 9 | redis-check-aof 10 | redis-check-rdb 11 | redis-check-dump 12 | redis-cli 13 | redis-sentinel 14 | redis-server 15 | doc-tools 16 | release 17 | misc/* 18 | src/release.h 19 | appendonly.aof 20 | SHORT_TERM_TODO 21 | release.h 22 | src/transfer.sh 23 | src/configs 24 | redis.ds 25 | src/redis.conf 26 | src/nodes.conf 27 | deps/lua/src/lua 28 | deps/lua/src/luac 29 | deps/lua/src/liblua.a 30 | .make-* 31 | .prerequisites 32 | *.dSYM 33 | Makefile.dep 34 | .vscode/* 35 | .idea/* 36 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/BUGS: -------------------------------------------------------------------------------- 1 | Please check https://github.com/antirez/redis/issues 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/INSTALL: -------------------------------------------------------------------------------- 1 | See README 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/Makefile: -------------------------------------------------------------------------------- 1 | # Top level makefile, the real shit is at src/Makefile 2 | 3 | default: all 4 | 5 | .DEFAULT: 6 | cd src && $(MAKE) $@ 7 | 8 | install: 9 | cd src && $(MAKE) $@ 10 | 11 | .PHONY: install 12 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/hiredis/.gitignore: -------------------------------------------------------------------------------- 1 | /hiredis-test 2 | /examples/hiredis-example* 3 | /*.o 4 | /*.so 5 | /*.dylib 6 | /*.a 7 | /*.pc 8 | *.dSYM 9 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/hiredis/appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor configuration file for CI build of hiredis on Windows (under Cygwin) 2 | environment: 3 | matrix: 4 | - CYG_BASH: C:\cygwin64\bin\bash 5 | CC: gcc 6 | - CYG_BASH: C:\cygwin\bin\bash 7 | CC: gcc 8 | CFLAGS: -m32 9 | CXXFLAGS: -m32 10 | LDFLAGS: -m32 11 | 12 | clone_depth: 1 13 | 14 | # Attempt to ensure we don't try to convert line endings to Win32 CRLF as this will cause build to fail 15 | init: 16 | - git config --global core.autocrlf input 17 | 18 | # Install needed build dependencies 19 | install: 20 | - '%CYG_BASH% -lc "cygcheck -dc cygwin"' 21 | 22 | build_script: 23 | - 'echo building...' 24 | - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER; exec 0 5 | 6 | class ExampleQt : public QObject { 7 | 8 | Q_OBJECT 9 | 10 | public: 11 | ExampleQt(const char * value, QObject * parent = 0) 12 | : QObject(parent), m_value(value) {} 13 | 14 | signals: 15 | void finished(); 16 | 17 | public slots: 18 | void run(); 19 | 20 | private: 21 | void finish() { emit finished(); } 22 | 23 | private: 24 | const char * m_value; 25 | redisAsyncContext * m_ctx; 26 | RedisQtAdapter m_adapter; 27 | 28 | friend 29 | void getCallback(redisAsyncContext *, void *, void *); 30 | }; 31 | 32 | #endif /* !__HIREDIS_EXAMPLE_QT_H */ 33 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #define _XOPEN_SOURCE 600 5 | #define _POSIX_C_SOURCE 200112L 6 | 7 | #if defined(__APPLE__) && defined(__MACH__) 8 | /* Enable TCP_KEEPALIVE */ 9 | #define _DARWIN_C_SOURCE 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/hiredis/hiredis.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis 8 | Description: Minimalistic C client library for Redis. 9 | Version: @PROJECT_VERSION@ 10 | Libs: -L${libdir} -lhiredis 11 | Cflags: -I${pkgincludedir} -D_FILE_OFFSET_BITS=64 12 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/hiredis/hiredis_ssl.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | pkgincludedir=${includedir}/hiredis 6 | 7 | Name: hiredis_ssl 8 | Description: SSL Support for hiredis. 9 | Version: @PROJECT_VERSION@ 10 | Requires: hiredis 11 | Libs: -L${libdir} -lhiredis_ssl 12 | Libs.private: -lssl -lcrypto 13 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/.autom4te.cfg: -------------------------------------------------------------------------------- 1 | begin-language: "Autoconf-without-aclocal-m4" 2 | args: --no-cache 3 | end-language: "Autoconf-without-aclocal-m4" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in autoconf; do 4 | echo "$i" 5 | $i 6 | if [ $? -ne 0 ]; then 7 | echo "Error $? in $i" 8 | exit 1 9 | fi 10 | done 11 | 12 | echo "./configure --enable-autogen $@" 13 | ./configure --enable-autogen $@ 14 | if [ $? -ne 0 ]; then 15 | echo "Error $? in ./configure" 16 | exit 1 17 | fi 18 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/bin/jemalloc.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | 7 | @LD_PRELOAD_VAR@=${libdir}/libjemalloc.@SOREV@ 8 | export @LD_PRELOAD_VAR@ 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/config.stamp.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/deps/jemalloc/config.stamp.in -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/arena_structs_a.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 2 | #define JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H 3 | 4 | #include "jemalloc/internal/bitmap.h" 5 | 6 | struct arena_slab_data_s { 7 | /* Per region allocated/deallocated bitmap. */ 8 | bitmap_t bitmap[BITMAP_GROUPS_MAX]; 9 | }; 10 | 11 | #endif /* JEMALLOC_INTERNAL_ARENA_STRUCTS_A_H */ 12 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/base_inlines.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_INLINES_H 2 | #define JEMALLOC_INTERNAL_BASE_INLINES_H 3 | 4 | static inline unsigned 5 | base_ind_get(const base_t *base) { 6 | return base->ind; 7 | } 8 | 9 | static inline bool 10 | metadata_thp_enabled(void) { 11 | return (opt_metadata_thp != metadata_thp_disabled); 12 | } 13 | #endif /* JEMALLOC_INTERNAL_BASE_INLINES_H */ 14 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/extent_mmap.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H 3 | 4 | extern bool opt_retain; 5 | 6 | void *extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, 7 | bool *zero, bool *commit); 8 | bool extent_dalloc_mmap(void *addr, size_t size); 9 | 10 | #endif /* JEMALLOC_INTERNAL_EXTENT_MMAP_EXTERNS_H */ 11 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/extent_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_TYPES_H 2 | #define JEMALLOC_INTERNAL_EXTENT_TYPES_H 3 | 4 | typedef struct extent_s extent_t; 5 | typedef struct extents_s extents_t; 6 | 7 | #define EXTENT_HOOKS_INITIALIZER NULL 8 | 9 | #define EXTENT_GROW_MAX_PIND (NPSIZES - 1) 10 | 11 | /* 12 | * When reuse (and split) an active extent, (1U << opt_lg_extent_max_active_fit) 13 | * is the max ratio between the size of the active extent and the new extent. 14 | */ 15 | #define LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT 6 16 | 17 | #endif /* JEMALLOC_INTERNAL_EXTENT_TYPES_H */ 18 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/private_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for symbol in `cat "$@"` ; do 4 | echo "#define ${symbol} JEMALLOC_N(${symbol})" 5 | done 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/public_namespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#define je_${n} JEMALLOC_N(${n})" 6 | done 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/public_unnamespace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for nm in `cat $1` ; do 4 | n=`echo ${nm} |tr ':' ' ' |awk '{print $1}'` 5 | echo "#undef je_${n}" 6 | done 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/spin.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_SPIN_H 2 | #define JEMALLOC_INTERNAL_SPIN_H 3 | 4 | #define SPIN_INITIALIZER {0U} 5 | 6 | typedef struct { 7 | unsigned iteration; 8 | } spin_t; 9 | 10 | static inline void 11 | spin_cpu_spinwait() { 12 | # if HAVE_CPU_SPINWAIT 13 | CPU_SPINWAIT; 14 | # else 15 | volatile int x = 0; 16 | x = x; 17 | # endif 18 | } 19 | 20 | static inline void 21 | spin_adaptive(spin_t *spin) { 22 | volatile uint32_t i; 23 | 24 | if (spin->iteration < 5) { 25 | for (i = 0; i < (1U << spin->iteration); i++) { 26 | spin_cpu_spinwait(); 27 | } 28 | spin->iteration++; 29 | } else { 30 | #ifdef _WIN32 31 | SwitchToThread(); 32 | #else 33 | sched_yield(); 34 | #endif 35 | } 36 | } 37 | 38 | #undef SPIN_INLINE 39 | 40 | #endif /* JEMALLOC_INTERNAL_SPIN_H */ 41 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/internal/tsd_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_TSD_TYPES_H 2 | #define JEMALLOC_INTERNAL_TSD_TYPES_H 3 | 4 | #define MALLOC_TSD_CLEANUPS_MAX 2 5 | 6 | typedef struct tsd_s tsd_t; 7 | typedef struct tsdn_s tsdn_t; 8 | typedef bool (*malloc_tsd_cleanup_t)(void); 9 | 10 | #endif /* JEMALLOC_INTERNAL_TSD_TYPES_H */ 11 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/jemalloc/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | objroot=$1 4 | 5 | cat < 5 | 6 | /* MSVC doesn't define _Bool or bool in C, but does have BOOL */ 7 | /* Note this doesn't pass autoconf's test because (bool) 0.5 != true */ 8 | /* Clang-cl uses MSVC headers, so needs msvc_compat, but has _Bool as 9 | * a built-in type. */ 10 | #ifndef __clang__ 11 | typedef BOOL _Bool; 12 | #endif 13 | 14 | #define bool _Bool 15 | #define true 1 16 | #define false 0 17 | 18 | #define __bool_true_false_are_defined 1 19 | 20 | #endif /* stdbool_h */ 21 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/include/msvc_compat/windows_extra.h: -------------------------------------------------------------------------------- 1 | #ifndef MSVC_COMPAT_WINDOWS_EXTRA_H 2 | #define MSVC_COMPAT_WINDOWS_EXTRA_H 3 | 4 | #include 5 | 6 | #endif /* MSVC_COMPAT_WINDOWS_EXTRA_H */ 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/jemalloc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | install_suffix=@install_suffix@ 6 | 7 | Name: jemalloc 8 | Description: A general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. 9 | URL: http://jemalloc.net/ 10 | Version: @jemalloc_version_major@.@jemalloc_version_minor@.@jemalloc_version_bugfix@_@jemalloc_version_nrev@ 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/msvc/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | How to build jemalloc for Windows 3 | ================================= 4 | 5 | 1. Install Cygwin with at least the following packages: 6 | * autoconf 7 | * autogen 8 | * gawk 9 | * grep 10 | * sed 11 | 12 | 2. Install Visual Studio 2015 or 2017 with Visual C++ 13 | 14 | 3. Add Cygwin\bin to the PATH environment variable 15 | 16 | 4. Open "x64 Native Tools Command Prompt for VS 2017" 17 | (note: x86/x64 doesn't matter at this point) 18 | 19 | 5. Generate header files: 20 | sh -c "CC=cl ./autogen.sh" 21 | 22 | 6. Now the project can be opened and built in Visual Studio: 23 | msvc\jemalloc_vc2017.sln 24 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/msvc/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/msvc/test_threads/test_threads_main.cpp: -------------------------------------------------------------------------------- 1 | #include "test_threads.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std::chrono_literals; 7 | 8 | int main(int argc, char** argv) { 9 | int rc = test_threads(); 10 | return rc; 11 | } 12 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/run_tests.sh: -------------------------------------------------------------------------------- 1 | $(dirname "$)")/scripts/gen_run_tests.py | bash 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/src/hash.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_HASH_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/src/hooks.c: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_preamble.h" 2 | 3 | /* 4 | * The hooks are a little bit screwy -- they're not genuinely exported in the 5 | * sense that we want them available to end-users, but we do want them visible 6 | * from outside the generated library, so that we can use them in test code. 7 | */ 8 | JEMALLOC_EXPORT 9 | void (*hooks_arena_new_hook)() = NULL; 10 | 11 | JEMALLOC_EXPORT 12 | void (*hooks_libc_hook)() = NULL; 13 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/src/mutex_pool.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_MUTEX_POOL_C_ 2 | 3 | #include "jemalloc/internal/jemalloc_preamble.h" 4 | #include "jemalloc/internal/jemalloc_internal_includes.h" 5 | 6 | #include "jemalloc/internal/mutex.h" 7 | #include "jemalloc/internal/mutex_pool.h" 8 | 9 | bool 10 | mutex_pool_init(mutex_pool_t *pool, const char *name, witness_rank_t rank) { 11 | for (int i = 0; i < MUTEX_POOL_SIZE; ++i) { 12 | if (malloc_mutex_init(&pool->mutexes[i], name, rank, 13 | malloc_mutex_address_ordered)) { 14 | return true; 15 | } 16 | } 17 | return false; 18 | } 19 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/src/prng.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_PRNG_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/src/ticker.c: -------------------------------------------------------------------------------- 1 | #define JEMALLOC_TICKER_C_ 2 | #include "jemalloc/internal/jemalloc_preamble.h" 3 | #include "jemalloc/internal/jemalloc_internal_includes.h" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/include/test/jemalloc_test_defs.h.in: -------------------------------------------------------------------------------- 1 | #include "jemalloc/internal/jemalloc_internal_defs.h" 2 | #include "jemalloc/internal/jemalloc_internal_decls.h" 3 | 4 | /* 5 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 6 | * dependencies are notoriously unportable in practice. 7 | */ 8 | #undef HAVE_SSE2 9 | #undef HAVE_ALTIVEC 10 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/include/test/mtx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mtx is a slightly simplified version of malloc_mutex. This code duplication 3 | * is unfortunate, but there are allocator bootstrapping considerations that 4 | * would leak into the test infrastructure if malloc_mutex were used directly 5 | * in tests. 6 | */ 7 | 8 | typedef struct { 9 | #ifdef _WIN32 10 | CRITICAL_SECTION lock; 11 | #elif (defined(JEMALLOC_OS_UNFAIR_LOCK)) 12 | os_unfair_lock lock; 13 | #elif (defined(JEMALLOC_OSSPIN)) 14 | OSSpinLock lock; 15 | #else 16 | pthread_mutex_t lock; 17 | #endif 18 | } mtx_t; 19 | 20 | bool mtx_init(mtx_t *mtx); 21 | void mtx_fini(mtx_t *mtx); 22 | void mtx_lock(mtx_t *mtx); 23 | void mtx_unlock(mtx_t *mtx); 24 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/include/test/thd.h: -------------------------------------------------------------------------------- 1 | /* Abstraction layer for threading in tests. */ 2 | #ifdef _WIN32 3 | typedef HANDLE thd_t; 4 | #else 5 | typedef pthread_t thd_t; 6 | #endif 7 | 8 | void thd_create(thd_t *thd, void *(*proc)(void *), void *arg); 9 | void thd_join(thd_t thd, void **ret); 10 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/include/test/timer.h: -------------------------------------------------------------------------------- 1 | /* Simple timer, for use in benchmark reporting. */ 2 | 3 | typedef struct { 4 | nstime_t t0; 5 | nstime_t t1; 6 | } timedelta_t; 7 | 8 | void timer_start(timedelta_t *timer); 9 | void timer_stop(timedelta_t *timer); 10 | uint64_t timer_usec(const timedelta_t *timer); 11 | void timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen); 12 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/integration/extent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/integration/mallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/integration/xallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/src/btalloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | void * 4 | btalloc(size_t size, unsigned bits) { 5 | return btalloc_0(size, bits); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/src/mq.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | /* 4 | * Sleep for approximately ns nanoseconds. No lower *nor* upper bound on sleep 5 | * time is guaranteed. 6 | */ 7 | void 8 | mq_nanosleep(unsigned ns) { 9 | assert(ns <= 1000*1000*1000); 10 | 11 | #ifdef _WIN32 12 | Sleep(ns / 1000); 13 | #else 14 | { 15 | struct timespec timeout; 16 | 17 | if (ns < 1000*1000*1000) { 18 | timeout.tv_sec = 0; 19 | timeout.tv_nsec = ns; 20 | } else { 21 | timeout.tv_sec = 1; 22 | timeout.tv_nsec = 0; 23 | } 24 | nanosleep(&timeout, NULL); 25 | } 26 | #endif 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/a0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_a0) { 4 | void *p; 5 | 6 | p = a0malloc(1); 7 | assert_ptr_not_null(p, "Unexpected a0malloc() error"); 8 | a0dalloc(p); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test_no_malloc_init( 15 | test_a0); 16 | } 17 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/arena_reset_prof.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | #define ARENA_RESET_PROF_C_ 3 | 4 | #include "arena_reset.c" 5 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/decay.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="dirty_decay_ms:1000,muzzy_decay_ms:1000,lg_tcache_max:0" 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/div.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/div.h" 4 | 5 | TEST_BEGIN(test_div_exhaustive) { 6 | for (size_t divisor = 2; divisor < 1000 * 1000; ++divisor) { 7 | div_info_t div_info; 8 | div_init(&div_info, divisor); 9 | size_t max = 1000 * divisor; 10 | if (max < 1000 * 1000) { 11 | max = 1000 * 1000; 12 | } 13 | for (size_t dividend = 0; dividend < 1000 * divisor; 14 | dividend += divisor) { 15 | size_t quotient = div_compute( 16 | &div_info, dividend); 17 | assert_zu_eq(dividend, quotient * divisor, 18 | "With divisor = %zu, dividend = %zu, " 19 | "got quotient %zu", divisor, dividend, quotient); 20 | } 21 | } 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test_no_reentrancy( 28 | test_div_exhaustive); 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/junk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:true" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/junk_alloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:alloc" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/junk_free.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,zero:false,junk:free" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Immediately purge to minimize fragmentation. 4 | export MALLOC_CONF="dirty_decay_ms:0,muzzy_decay_ms:0" 5 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_accum.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_active.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_thread_active_init:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_gdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,prof_gdump:true" 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_idump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="tcache:false" 4 | if [ "x${enable_prof}" = "x1" ] ; then 5 | export MALLOC_CONF="${MALLOC_CONF},prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0" 6 | fi 7 | 8 | 9 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_reset.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_tctx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/prof_thread_name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_prof}" = "x1" ] ; then 4 | export MALLOC_CONF="prof:true,prof_active:false" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/spin.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #include "jemalloc/internal/spin.h" 4 | 5 | TEST_BEGIN(test_spin) { 6 | spin_t spinner = SPIN_INITIALIZER; 7 | 8 | for (unsigned i = 0; i < 100; i++) { 9 | spin_adaptive(&spinner); 10 | } 11 | } 12 | TEST_END 13 | 14 | int 15 | main(void) { 16 | return test( 17 | test_spin); 18 | } 19 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/jemalloc/test/unit/zero.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="abort:false,junk:false,zero:true" 5 | fi 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/linenoise/.gitignore: -------------------------------------------------------------------------------- 1 | linenoise_example 2 | *.dSYM 3 | history.txt 4 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/linenoise/Makefile: -------------------------------------------------------------------------------- 1 | STD= 2 | WARN= -Wall 3 | OPT= -Os 4 | 5 | R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) 6 | R_LDFLAGS= $(LDFLAGS) 7 | DEBUG= -g 8 | 9 | R_CC=$(CC) $(R_CFLAGS) 10 | R_LD=$(CC) $(R_LDFLAGS) 11 | 12 | linenoise.o: linenoise.h linenoise.c 13 | 14 | linenoise_example: linenoise.o example.o 15 | $(R_LD) -o $@ $^ 16 | 17 | .c.o: 18 | $(R_CC) -c $< 19 | 20 | clean: 21 | rm -f linenoise_example *.o 22 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/doc/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/deps/lua/doc/cover.png -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/etc/all.c: -------------------------------------------------------------------------------- 1 | /* 2 | * all.c -- Lua core, libraries and interpreter in a single file 3 | */ 4 | 5 | #define luaall_c 6 | 7 | #include "lapi.c" 8 | #include "lcode.c" 9 | #include "ldebug.c" 10 | #include "ldo.c" 11 | #include "ldump.c" 12 | #include "lfunc.c" 13 | #include "lgc.c" 14 | #include "llex.c" 15 | #include "lmem.c" 16 | #include "lobject.c" 17 | #include "lopcodes.c" 18 | #include "lparser.c" 19 | #include "lstate.c" 20 | #include "lstring.c" 21 | #include "ltable.c" 22 | #include "ltm.c" 23 | #include "lundump.c" 24 | #include "lvm.c" 25 | #include "lzio.c" 26 | 27 | #include "lauxlib.c" 28 | #include "lbaselib.c" 29 | #include "ldblib.c" 30 | #include "liolib.c" 31 | #include "linit.c" 32 | #include "lmathlib.c" 33 | #include "loadlib.c" 34 | #include "loslib.c" 35 | #include "lstrlib.c" 36 | #include "ltablib.c" 37 | 38 | #include "lua.c" 39 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/etc/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/etc/lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/deps/lua/etc/lua.ico -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/etc/lua.pc: -------------------------------------------------------------------------------- 1 | # lua.pc -- pkg-config data for Lua 2 | 3 | # vars from install Makefile 4 | 5 | # grep '^V=' ../Makefile 6 | V= 5.1 7 | # grep '^R=' ../Makefile 8 | R= 5.1.5 9 | 10 | # grep '^INSTALL_.*=' ../Makefile | sed 's/INSTALL_TOP/prefix/' 11 | prefix= /usr/local 12 | INSTALL_BIN= ${prefix}/bin 13 | INSTALL_INC= ${prefix}/include 14 | INSTALL_LIB= ${prefix}/lib 15 | INSTALL_MAN= ${prefix}/man/man1 16 | INSTALL_LMOD= ${prefix}/share/lua/${V} 17 | INSTALL_CMOD= ${prefix}/lib/lua/${V} 18 | 19 | # canonical vars 20 | exec_prefix=${prefix} 21 | libdir=${exec_prefix}/lib 22 | includedir=${prefix}/include 23 | 24 | Name: Lua 25 | Description: An Extensible Extension Language 26 | Version: ${R} 27 | Requires: 28 | Libs: -L${libdir} -llua -lm 29 | Cflags: -I${includedir} 30 | 31 | # (end of lua.pc) 32 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/src/fpconv.h: -------------------------------------------------------------------------------- 1 | /* Lua CJSON floating point conversion routines */ 2 | 3 | /* Buffer required to store the largest string representation of a double. 4 | * 5 | * Longest double printed with %.14g is 21 characters long: 6 | * -1.7976931348623e+308 */ 7 | # define FPCONV_G_FMT_BUFSIZE 32 8 | 9 | #ifdef USE_INTERNAL_FPCONV 10 | static inline void fpconv_init() 11 | { 12 | /* Do nothing - not required */ 13 | } 14 | #else 15 | extern void fpconv_init(); 16 | #endif 17 | 18 | extern int fpconv_g_fmt(char*, double, int); 19 | extern double fpconv_strtod(const char*, char**); 20 | 21 | /* vi:ai et sw=4 ts=4: 22 | */ 23 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/deps/lua/test/bisect.lua: -------------------------------------------------------------------------------- 1 | -- bisection method for solving non-linear equations 2 | 3 | delta=1e-6 -- tolerance 4 | 5 | function bisect(f,a,b,fa,fb) 6 | local c=(a+b)/2 7 | io.write(n," c=",c," a=",a," b=",b,"\n") 8 | if c==a or c==b or math.abs(a-b) /tmp/jemalloc.tar.bz2 6 | tar xvjf /tmp/jemalloc.tar.bz2 7 | rm -rf jemalloc 8 | mv jemalloc-${VER} jemalloc 9 | echo "Use git status, add all files and commit changes." 10 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/runtest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | $TCLSH tests/test_helper.tcl "${@}" 15 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/runtest-cluster: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/cluster/run.tcl $* 15 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/runtest-moduleapi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis test" 12 | exit 1 13 | fi 14 | 15 | make -C tests/modules && \ 16 | $TCLSH tests/test_helper.tcl \ 17 | --single unit/moduleapi/commandfilter \ 18 | --single unit/moduleapi/fork \ 19 | --single unit/moduleapi/testrdb \ 20 | --single unit/moduleapi/infotest \ 21 | --single unit/moduleapi/propagate \ 22 | --single unit/moduleapi/hooks \ 23 | --single unit/moduleapi/misc \ 24 | --single unit/moduleapi/blockonkeys \ 25 | --single unit/moduleapi/scan \ 26 | --single unit/moduleapi/datatype \ 27 | --single unit/moduleapi/auth \ 28 | "${@}" 29 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/runtest-sentinel: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | TCL_VERSIONS="8.5 8.6" 3 | TCLSH="" 4 | 5 | for VERSION in $TCL_VERSIONS; do 6 | TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL 7 | done 8 | 9 | if [ -z $TCLSH ] 10 | then 11 | echo "You need tcl 8.5 or newer in order to run the Redis Sentinel test" 12 | exit 1 13 | fi 14 | $TCLSH tests/sentinel/run.tcl $* 15 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/.gitignore: -------------------------------------------------------------------------------- 1 | *.gcda 2 | *.gcno 3 | *.gcov 4 | redis.info 5 | lcov-html 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/crc64.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC64_H 2 | #define CRC64_H 3 | 4 | #include 5 | 6 | void crc64_init(void); 7 | uint64_t crc64(uint64_t crc, const unsigned char *s, uint64_t l); 8 | 9 | #ifdef REDIS_TEST 10 | int crc64Test(int argc, char *argv[]); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/geo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEO_H__ 2 | #define __GEO_H__ 3 | 4 | #include "server.h" 5 | 6 | /* Structures used inside geo.c in order to represent points and array of 7 | * points on the earth. */ 8 | typedef struct geoPoint { 9 | double longitude; 10 | double latitude; 11 | double dist; 12 | double score; 13 | char *member; 14 | } geoPoint; 15 | 16 | typedef struct geoArray { 17 | struct geoPoint *array; 18 | size_t buckets; 19 | size_t used; 20 | } geoArray; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/mkreleasehdr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n1` 3 | GIT_DIRTY=`git diff --no-ext-diff 2> /dev/null | wc -l` 4 | BUILD_ID=`uname -n`"-"`date +%s` 5 | if [ -n "$SOURCE_DATE_EPOCH" ]; then 6 | BUILD_ID=$(date -u -d "@$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" +%s 2>/dev/null || date -u +%s) 7 | fi 8 | test -f release.h || touch release.h 9 | (cat release.h | grep SHA1 | grep $GIT_SHA1) && \ 10 | (cat release.h | grep DIRTY | grep $GIT_DIRTY) && exit 0 # Already up-to-date 11 | echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h 12 | echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h 13 | echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h 14 | touch release.c # Force recompile of release.c 15 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/modules/.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.xo 3 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef SHA1_H 2 | #define SHA1_H 3 | /* ================ sha1.h ================ */ 4 | /* 5 | SHA-1 in C 6 | By Steve Reid 7 | 100% Public Domain 8 | */ 9 | 10 | typedef struct { 11 | uint32_t state[5]; 12 | uint32_t count[2]; 13 | unsigned char buffer[64]; 14 | } SHA1_CTX; 15 | 16 | void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]); 17 | void SHA1Init(SHA1_CTX* context); 18 | void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len); 19 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context); 20 | 21 | #ifdef REDIS_TEST 22 | int sha1Test(int argc, char **argv); 23 | #endif 24 | #endif 25 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/valgrind.sup: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Cond 4 | fun:lzf_compress 5 | } 6 | 7 | { 8 | 9 | Memcheck:Value4 10 | fun:lzf_compress 11 | } 12 | 13 | { 14 | 15 | Memcheck:Value8 16 | fun:lzf_compress 17 | } 18 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/src/version.h: -------------------------------------------------------------------------------- 1 | #define REDIS_VERSION "6.0.3" 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/assets/default.conf: -------------------------------------------------------------------------------- 1 | # Redis configuration for testing. 2 | 3 | always-show-logo yes 4 | notify-keyspace-events KEA 5 | daemonize no 6 | pidfile /var/run/redis.pid 7 | port 6379 8 | timeout 0 9 | bind 127.0.0.1 10 | loglevel verbose 11 | logfile '' 12 | databases 16 13 | latency-monitor-threshold 1 14 | 15 | save 900 1 16 | save 300 10 17 | save 60 10000 18 | 19 | rdbcompression yes 20 | dbfilename dump.rdb 21 | dir ./ 22 | 23 | slave-serve-stale-data yes 24 | appendonly no 25 | appendfsync everysec 26 | no-appendfsync-on-rewrite no 27 | activerehashing yes 28 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/assets/encodings.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/tests/assets/encodings.rdb -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/assets/hash-zipmap.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter07/redis-6.0.3/tests/assets/hash-zipmap.rdb -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/cluster/run.tcl: -------------------------------------------------------------------------------- 1 | # Cluster test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/cluster 6 | source cluster.tcl 7 | source ../instances.tcl 8 | source ../../support/cluster.tcl ; # Redis Cluster client. 9 | 10 | set ::instances_count 20 ; # How many instances we use at max. 11 | set ::tlsdir "../../tls" 12 | 13 | proc main {} { 14 | parse_options 15 | spawn_instance redis $::redis_base_port $::instances_count { 16 | "cluster-enabled yes" 17 | "appendonly yes" 18 | } 19 | run_tests 20 | cleanup 21 | end_tests 22 | } 23 | 24 | if {[catch main e]} { 25 | puts $::errorInfo 26 | if {$::pause_on_error} pause_on_error 27 | cleanup 28 | exit 1 29 | } 30 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/cluster/tests/helpers/onlydots.tcl: -------------------------------------------------------------------------------- 1 | # Read the standard input and only shows dots in the output, filtering out 2 | # all the other characters. Designed to avoid bufferization so that when 3 | # we get the output of redis-trib and want to show just the dots, we'll see 4 | # the dots as soon as redis-trib will output them. 5 | 6 | fconfigure stdin -buffering none 7 | 8 | while 1 { 9 | set c [read stdin 1] 10 | if {$c eq {}} { 11 | exit 0; # EOF 12 | } elseif {$c eq {.}} { 13 | puts -nonewline . 14 | flush stdout 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/cluster/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/helpers/bg_complex_data.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | source tests/support/util.tcl 3 | 4 | set ::tlsdir "tests/tls" 5 | 6 | proc bg_complex_data {host port db ops tls} { 7 | set r [redis $host $port 0 $tls] 8 | $r select $db 9 | createComplexDataset $r $ops 10 | } 11 | 12 | bg_complex_data [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] [lindex $argv 4] 13 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/helpers/gen_write_load.tcl: -------------------------------------------------------------------------------- 1 | source tests/support/redis.tcl 2 | 3 | set ::tlsdir "tests/tls" 4 | 5 | proc gen_write_load {host port seconds tls} { 6 | set start_time [clock seconds] 7 | set r [redis $host $port 1 $tls] 8 | $r select 9 9 | while 1 { 10 | $r set [expr rand()] [expr rand()] 11 | if {[clock seconds]-$start_time > $seconds} { 12 | exit 0 13 | } 14 | } 15 | } 16 | 17 | gen_write_load [lindex $argv 0] [lindex $argv 1] [lindex $argv 2] [lindex $argv 3] 18 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/sentinel/run.tcl: -------------------------------------------------------------------------------- 1 | # Sentinel test suite. Copyright (C) 2014 Salvatore Sanfilippo antirez@gmail.com 2 | # This software is released under the BSD License. See the COPYING file for 3 | # more information. 4 | 5 | cd tests/sentinel 6 | source ../instances.tcl 7 | 8 | set ::instances_count 5 ; # How many instances we use at max. 9 | set ::tlsdir "../../tls" 10 | 11 | proc main {} { 12 | parse_options 13 | spawn_instance sentinel $::sentinel_base_port $::instances_count 14 | spawn_instance redis $::redis_base_port $::instances_count 15 | run_tests 16 | cleanup 17 | end_tests 18 | } 19 | 20 | if {[catch main e]} { 21 | puts $::errorInfo 22 | cleanup 23 | exit 1 24 | } 25 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/sentinel/tests/03-runtime-reconf.tcl: -------------------------------------------------------------------------------- 1 | # Test runtime reconfiguration command SENTINEL SET. 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/sentinel/tests/04-slave-selection.tcl: -------------------------------------------------------------------------------- 1 | # Test slave selection algorithm. 2 | # 3 | # This unit should test: 4 | # 1) That when there are no suitable slaves no failover is performed. 5 | # 2) That among the available slaves, the one with better offset is picked. 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/sentinel/tmp/.gitignore: -------------------------------------------------------------------------------- 1 | redis_* 2 | sentinel_* 3 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/support/cli.tcl: -------------------------------------------------------------------------------- 1 | proc rediscli_tls_config {testsdir} { 2 | set tlsdir [file join $testsdir tls] 3 | set cert [file join $tlsdir redis.crt] 4 | set key [file join $tlsdir redis.key] 5 | set cacert [file join $tlsdir ca.crt] 6 | 7 | if {$::tls} { 8 | return [list --tls --cert $cert --key $key --cacert $cacert] 9 | } else { 10 | return {} 11 | } 12 | } 13 | 14 | proc rediscli {port {opts {}}} { 15 | set cmd [list src/redis-cli -p $port] 16 | lappend cmd {*}[rediscli_tls_config "tests"] 17 | lappend cmd {*}$opts 18 | return $cmd 19 | } 20 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/support/tmpfile.tcl: -------------------------------------------------------------------------------- 1 | set ::tmpcounter 0 2 | set ::tmproot "./tests/tmp" 3 | file mkdir $::tmproot 4 | 5 | # returns a dirname unique to this process to write to 6 | proc tmpdir {basename} { 7 | set dir [file join $::tmproot $basename.[pid].[incr ::tmpcounter]] 8 | file mkdir $dir 9 | set _ $dir 10 | } 11 | 12 | # return a filename unique to this process to write to 13 | proc tmpfile {basename} { 14 | file join $::tmproot $basename.[pid].[incr ::tmpcounter] 15 | } 16 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/unit/auth.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"auth"}} { 2 | test {AUTH fails if there is no password configured server side} { 3 | catch {r auth foo} err 4 | set _ $err 5 | } {ERR*any password*} 6 | } 7 | 8 | start_server {tags {"auth"} overrides {requirepass foobar}} { 9 | test {AUTH fails when a wrong password is given} { 10 | catch {r auth wrong!} err 11 | set _ $err 12 | } {WRONGPASS*} 13 | 14 | test {Arbitrary command gives an error when AUTH is required} { 15 | catch {r set foo bar} err 16 | set _ $err 17 | } {NOAUTH*} 18 | 19 | test {AUTH succeeds when the right password is given} { 20 | r auth foobar 21 | } {OK} 22 | 23 | test {Once AUTH succeeded we can actually send commands to the server} { 24 | r set foo 100 25 | r incr foo 26 | } {101} 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/unit/limits.tcl: -------------------------------------------------------------------------------- 1 | start_server {tags {"limits"} overrides {maxclients 10}} { 2 | if {$::tls} { 3 | set expected_code "*I/O error*" 4 | } else { 5 | set expected_code "*ERR max*reached*" 6 | } 7 | test {Check if maxclients works refusing connections} { 8 | set c 0 9 | catch { 10 | while {$c < 50} { 11 | incr c 12 | set rd [redis_deferring_client] 13 | $rd ping 14 | $rd read 15 | after 100 16 | } 17 | } e 18 | assert {$c > 8 && $c <= 10} 19 | set e 20 | } $expected_code 21 | } 22 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/unit/printver.tcl: -------------------------------------------------------------------------------- 1 | start_server {} { 2 | set i [r info] 3 | regexp {redis_version:(.*?)\r\n} $i - version 4 | regexp {redis_git_sha1:(.*?)\r\n} $i - sha1 5 | puts "Testing Redis version $version ($sha1)" 6 | } 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/tests/unit/type/list-common.tcl: -------------------------------------------------------------------------------- 1 | # We need a value larger than list-max-ziplist-value to make sure 2 | # the list has the right encoding when it is swapped in again. 3 | array set largevalue {} 4 | set largevalue(ziplist) "hello" 5 | set largevalue(linkedlist) [string repeat "hello" 4] 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/build-static-symbols.tcl: -------------------------------------------------------------------------------- 1 | # Build a symbol table for static symbols of redis.c 2 | # Useful to get stack traces on segfault without a debugger. See redis.c 3 | # for more information. 4 | # 5 | # Copyright(C) 2009 Salvatore Sanfilippo, under the BSD license. 6 | 7 | set fd [open redis.c] 8 | set symlist {} 9 | while {[gets $fd line] != -1} { 10 | if {[regexp {^static +[A-z0-9]+[ *]+([A-z0-9]*)\(} $line - sym]} { 11 | lappend symlist $sym 12 | } 13 | } 14 | set symlist [lsort -unique $symlist] 15 | puts "static struct redisFunctionSym symsTable\[\] = {" 16 | foreach sym $symlist { 17 | puts "{\"$sym\",(unsigned long)$sym}," 18 | } 19 | puts "{NULL,0}" 20 | puts "};" 21 | 22 | close $fd 23 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/create-cluster/.gitignore: -------------------------------------------------------------------------------- 1 | config.sh 2 | *.rdb 3 | *.aof 4 | *.conf 5 | *.log 6 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/gen-test-certs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p tests/tls 3 | openssl genrsa -out tests/tls/ca.key 4096 4 | openssl req \ 5 | -x509 -new -nodes -sha256 \ 6 | -key tests/tls/ca.key \ 7 | -days 3650 \ 8 | -subj '/O=Redis Test/CN=Certificate Authority' \ 9 | -out tests/tls/ca.crt 10 | openssl genrsa -out tests/tls/redis.key 2048 11 | openssl req \ 12 | -new -sha256 \ 13 | -key tests/tls/redis.key \ 14 | -subj '/O=Redis Test/CN=Server' | \ 15 | openssl x509 \ 16 | -req -sha256 \ 17 | -CA tests/tls/ca.crt \ 18 | -CAkey tests/tls/ca.key \ 19 | -CAserial tests/tls/ca.txt \ 20 | -CAcreateserial \ 21 | -days 365 \ 22 | -out tests/tls/redis.crt 23 | openssl dhparam -out tests/tls/redis.dh 2048 24 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/graphs/commits-over-time/README.md: -------------------------------------------------------------------------------- 1 | This Tcl script is what I used in order to generate the graph you 2 | can find at http://antirez.com/news/98. It's really quick & dirty, more 3 | a trow away program than anything else, but probably could be reused or 4 | modified in the future in order to visualize other similar data or an 5 | updated version of the same data. 6 | 7 | The usage is trivial: 8 | 9 | ./genhtml.tcl > output.html 10 | 11 | The generated HTML is quite broken but good enough to grab a screenshot 12 | from the browser. Feel free to improve it if you got time / interest. 13 | 14 | Note that the code filtering the tags, and the hardcoded branch name, does 15 | not make the script, as it is, able to analyze a different repository. 16 | However the changes needed are trivial. 17 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/hashtable/README: -------------------------------------------------------------------------------- 1 | Hash table implementation related utilities. 2 | 3 | rehashing.c 4 | --- 5 | 6 | Visually show buckets in the two hash tables between rehashings. Also stress 7 | test getRandomKeys() implementation, that may actually disappear from 8 | Redis soon, however visualization some code is reusable in new bugs 9 | investigation. 10 | 11 | Compile with: 12 | 13 | cc -I ../../src/ rehashing.c ../../src/zmalloc.c ../../src/dict.c -o rehashing_test 14 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/hyperloglog/.gitignore: -------------------------------------------------------------------------------- 1 | *.txt 2 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/hyperloglog/hll-err.rb: -------------------------------------------------------------------------------- 1 | # hll-err.rb - Copyright (C) 2014 Salvatore Sanfilippo 2 | # BSD license, See the COPYING file for more information. 3 | # 4 | # Check error of HyperLogLog Redis implementation for different set sizes. 5 | 6 | require 'rubygems' 7 | require 'redis' 8 | require 'digest/sha1' 9 | 10 | r = Redis.new 11 | r.del('hll') 12 | i = 0 13 | while true do 14 | 100.times { 15 | elements = [] 16 | 1000.times { 17 | ele = Digest::SHA1.hexdigest(i.to_s) 18 | elements << ele 19 | i += 1 20 | } 21 | r.pfadd('hll',elements) 22 | } 23 | approx = r.pfcount('hll') 24 | abs_err = (approx-i).abs 25 | rel_err = 100.to_f*abs_err/i 26 | puts "#{i} vs #{approx}: #{rel_err}%" 27 | end 28 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/lru/README: -------------------------------------------------------------------------------- 1 | The test-lru.rb program can be used in order to check the behavior of the 2 | Redis approximated LRU algorithm against the theoretical output of true 3 | LRU algorithm. 4 | 5 | In order to use the program you need to recompile Redis setting the define 6 | REDIS_LRU_CLOCK_RESOLUTION to 1, by editing the file server.h. 7 | This allows to execute the program in a fast way since the 1 ms resolution 8 | is enough for all the objects to have a different enough time stamp during 9 | the test. 10 | 11 | The program is executed like this: 12 | 13 | ruby test-lru.rb /tmp/lru.html 14 | 15 | You can optionally specify a number of times to run, so that the program 16 | will output averages of different runs, by adding an additional argument. 17 | For instance in order to run the test 10 times use: 18 | 19 | ruby test-lru.rb /tmp/lru.html 10 20 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/releasetools/01_create_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ $# != "1" ] 3 | then 4 | echo "Usage: ./mkrelease.sh " 5 | exit 1 6 | fi 7 | 8 | TAG=$1 9 | TARNAME="redis-${TAG}.tar" 10 | echo "Generating /tmp/${TARNAME}" 11 | cd ~/hack/redis 12 | git archive $TAG --prefix redis-${TAG}/ > /tmp/$TARNAME || exit 1 13 | echo "Gizipping the archive" 14 | rm -f /tmp/$TARNAME.gz 15 | gzip -9 /tmp/$TARNAME 16 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/releasetools/02_upload_tarball.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Uploading..." 3 | scp /tmp/redis-${1}.tar.gz antirez@antirez.com:/var/virtual/download.redis.io/httpdocs/releases/ 4 | echo "Updating web site... (press any key if it is a stable release, or Ctrl+C)" 5 | read x 6 | ssh antirez@antirez.com "cd /var/virtual/download.redis.io/httpdocs; ./update.sh ${1}" 7 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/releasetools/04_release_hash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SHA=$(curl -s http://download.redis.io/releases/redis-${1}.tar.gz | shasum -a 256 | cut -f 1 -d' ') 3 | ENTRY="hash redis-${1}.tar.gz sha256 $SHA http://download.redis.io/releases/redis-${1}.tar.gz" 4 | echo $ENTRY >> ~/hack/redis-hashes/README 5 | vi ~/hack/redis-hashes/README 6 | echo "Press any key to commit, Ctrl-C to abort)." 7 | read yes 8 | (cd ~/hack/redis-hashes; git commit -a -m "${1} hash."; git push) 9 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/srandmember/README.md: -------------------------------------------------------------------------------- 1 | The utilities in this directory plot the distribution of SRANDMEMBER to 2 | evaluate how fair it is. 3 | 4 | See http://theshfl.com/redis_sets for more information on the topic that lead 5 | to such investigation fix. 6 | 7 | showdist.rb -- shows the distribution of the frequency elements are returned. 8 | The x axis is the number of times elements were returned, and 9 | the y axis is how many elements were returned with such 10 | frequency. 11 | 12 | showfreq.rb -- shows the frequency each element was returned. 13 | The x axis is the element number. 14 | The y axis is the times it was returned. 15 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/srandmember/showdist.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 100.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Convert into frequency distribution 21 | dist = {} 22 | freq.each{|item,count| 23 | dist[count] = 0 if dist[count] == nil 24 | dist[count] += 1 25 | } 26 | 27 | min = dist.keys.min 28 | max = dist.keys.max 29 | (min..max).each{|x| 30 | count = dist[x] 31 | count = 0 if count == nil 32 | puts "#{x} -> #{"*"*count}" 33 | } 34 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/srandmember/showfreq.rb: -------------------------------------------------------------------------------- 1 | require 'redis' 2 | 3 | r = Redis.new 4 | r.select(9) 5 | r.del("myset"); 6 | r.sadd("myset",(0..999).to_a) 7 | freq = {} 8 | 500.times { 9 | res = r.pipelined { 10 | 1000.times { 11 | r.srandmember("myset") 12 | } 13 | } 14 | res.each{|ele| 15 | freq[ele] = 0 if freq[ele] == nil 16 | freq[ele] += 1 17 | } 18 | } 19 | 20 | # Print the frequency each element was yeld to process it with gnuplot 21 | freq.each{|item,count| 22 | puts "#{item} #{count}" 23 | } 24 | -------------------------------------------------------------------------------- /Chapter07/redis-6.0.3/utils/whatisdoing.sh: -------------------------------------------------------------------------------- 1 | # This script is from http://poormansprofiler.org/ 2 | # 3 | # NOTE: Instead of using this script, you should use the Redis 4 | # Software Watchdog, which provides a similar functionality but in 5 | # a more reliable / easy to use way. 6 | # 7 | # Check http://redis.io/topics/latency for more information. 8 | 9 | #!/bin/bash 10 | nsamples=1 11 | sleeptime=0 12 | pid=$(ps auxww | grep '[r]edis-server' | awk '{print $2}') 13 | 14 | for x in $(seq 1 $nsamples) 15 | do 16 | gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid 17 | sleep $sleeptime 18 | done | \ 19 | awk ' 20 | BEGIN { s = ""; } 21 | /Thread/ { print s; s = ""; } 22 | /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } } 23 | END { print s }' | \ 24 | sort | uniq -c | sort -r -n -k 1,1 25 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger/AsyncLogger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter09/code/AsyncLogger/AsyncLogger.cpp -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // AsyncLogger.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger1/AsyncLogger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter09/code/AsyncLogger1/AsyncLogger.cpp -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // AsyncLogger.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger1/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLogger1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLoggerLinux.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter09/code/AsyncLoggerLinux.cpp -------------------------------------------------------------------------------- /Chapter09/code/AsyncLoggerWindows/AsyncLogger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/Chapter09/code/AsyncLoggerWindows/AsyncLogger.cpp -------------------------------------------------------------------------------- /Chapter09/code/AsyncLoggerWindows/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // AsyncLogger.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLoggerWindows/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /Chapter09/code/AsyncLoggerWindows/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 《C++ 服务器开发精髓》随书配套源码 2 | 3 | 4 | 5 | 这是《C++ 服务器开发精髓》的随书配套源码。 6 | 7 | ![](https://github.com/balloonwj/mybooksources/blob/master/bookCover.jpeg?raw=true) 8 | 9 | 10 | 11 | ### 购买链接 12 | 13 | https://item.jd.com/13312460.html 14 | 15 | 16 | 17 | ### 相关链接: 18 | 19 | [在 2021 年写一本 C++ 图书是一种什么体验?](https://mp.weixin.qq.com/s/gEtCIc5AtSXhUp0ClyEvwg) 20 | 21 | 22 | 23 | ### 联系方式 24 | 25 | 你可以加入本书读者交流群一起交流学习,加微信 **easy_coder** 拉你进群。 26 | 27 | 28 | 29 | ### 微信公众号 30 | 31 | 微信搜索【**高性能服务器开发**】或者微信扫码关注。 32 | 33 | ![](https://github.com/balloonwj/mybooksources/blob/master/easyserverdev.png?raw=true) 34 | -------------------------------------------------------------------------------- /bookCover.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/bookCover.jpeg -------------------------------------------------------------------------------- /easyserverdev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/easyserverdev.png -------------------------------------------------------------------------------- /图书勘误/图书勘误.docx.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/balloonwj/mybooksources/5bf02a748de26060cf6876fcea8f86a7170aca79/图书勘误/图书勘误.docx.zip --------------------------------------------------------------------------------