├── meiru ├── skynet │ ├── 3rd │ │ ├── jemalloc │ │ │ ├── config.stamp │ │ │ ├── config.stamp.in │ │ │ ├── test │ │ │ │ ├── unit │ │ │ │ │ ├── junk_alloc.c │ │ │ │ │ ├── junk_free.c │ │ │ │ │ ├── arena_reset_prof.sh │ │ │ │ │ ├── binshard.sh │ │ │ │ │ ├── decay.sh │ │ │ │ │ ├── arena_reset_prof.c │ │ │ │ │ ├── junk.sh │ │ │ │ │ ├── pack.sh │ │ │ │ │ ├── prof_log.sh │ │ │ │ │ ├── prof_tctx.sh │ │ │ │ │ ├── zero.sh │ │ │ │ │ ├── junk_free.sh │ │ │ │ │ ├── junk_alloc.sh │ │ │ │ │ ├── prof_thread_name.sh │ │ │ │ │ ├── prof_reset.sh │ │ │ │ │ ├── prof_gdump.sh │ │ │ │ │ ├── prof_active.sh │ │ │ │ │ ├── prof_accum.sh │ │ │ │ │ ├── prof_idump.sh │ │ │ │ │ ├── a0.c │ │ │ │ │ ├── spin.c │ │ │ │ │ ├── div.c │ │ │ │ │ ├── pages.c │ │ │ │ │ ├── test_hooks.c │ │ │ │ │ ├── prof_idump.c │ │ │ │ │ ├── slab.c │ │ │ │ │ └── sc.c │ │ │ │ ├── src │ │ │ │ │ ├── math.c │ │ │ │ │ ├── btalloc_0.c │ │ │ │ │ ├── btalloc_1.c │ │ │ │ │ ├── btalloc.c │ │ │ │ │ ├── mq.c │ │ │ │ │ └── thd.c │ │ │ │ ├── integration │ │ │ │ │ ├── extent.sh │ │ │ │ │ ├── mallocx.sh │ │ │ │ │ ├── smallocx.sh │ │ │ │ │ ├── xallocx.sh │ │ │ │ │ ├── slab_sizes.sh │ │ │ │ │ ├── malloc.c │ │ │ │ │ └── cpp │ │ │ │ │ │ └── basic.cpp │ │ │ │ └── include │ │ │ │ │ └── test │ │ │ │ │ ├── thd.h │ │ │ │ │ ├── jemalloc_test_defs.h.in │ │ │ │ │ ├── timer.h │ │ │ │ │ ├── jemalloc_test_defs.h │ │ │ │ │ ├── mtx.h │ │ │ │ │ └── btalloc.h │ │ │ ├── VERSION │ │ │ ├── run_tests.sh │ │ │ ├── msvc │ │ │ │ ├── test_threads │ │ │ │ │ ├── test_threads.h │ │ │ │ │ └── test_threads_main.cpp │ │ │ │ ├── ReadMe.txt │ │ │ │ └── projects │ │ │ │ │ ├── vc2015 │ │ │ │ │ └── test_threads │ │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ │ │ └── vc2017 │ │ │ │ │ └── test_threads │ │ │ │ │ └── test_threads.vcxproj.filters │ │ │ ├── src │ │ │ │ ├── hash.c │ │ │ │ ├── prng.c │ │ │ │ ├── ticker.c │ │ │ │ ├── test_hooks.c │ │ │ │ ├── mutex_pool.c │ │ │ │ └── extent_mmap.c │ │ │ ├── include │ │ │ │ ├── jemalloc │ │ │ │ │ ├── internal │ │ │ │ │ │ ├── private_namespace.sh │ │ │ │ │ │ ├── public_unnamespace.sh │ │ │ │ │ │ ├── public_namespace.sh │ │ │ │ │ │ ├── tsd_types.h │ │ │ │ │ │ ├── arena_structs_a.h │ │ │ │ │ │ ├── base_inlines.h │ │ │ │ │ │ ├── extent_mmap.h │ │ │ │ │ │ ├── extent_types.h │ │ │ │ │ │ ├── bin_types.h │ │ │ │ │ │ ├── public_unnamespace.h │ │ │ │ │ │ ├── public_symbols.txt │ │ │ │ │ │ ├── spin.h │ │ │ │ │ │ ├── extent_dss.h │ │ │ │ │ │ ├── test_hooks.h │ │ │ │ │ │ ├── base_externs.h │ │ │ │ │ │ ├── stats.h │ │ │ │ │ │ └── public_namespace.h │ │ │ │ │ ├── jemalloc_rename.sh │ │ │ │ │ └── jemalloc.sh │ │ │ │ └── msvc_compat │ │ │ │ │ ├── windows_extra.h │ │ │ │ │ └── C99 │ │ │ │ │ └── stdbool.h │ │ │ ├── bin │ │ │ │ ├── jemalloc.sh │ │ │ │ └── jemalloc.sh.in │ │ │ ├── doc │ │ │ │ ├── manpages.xsl.in │ │ │ │ ├── manpages.xsl │ │ │ │ ├── html.xsl.in │ │ │ │ ├── html.xsl │ │ │ │ └── stylesheet.xsl │ │ │ ├── autogen.sh │ │ │ ├── jemalloc.pc │ │ │ ├── jemalloc.pc.in │ │ │ └── README │ │ ├── lua-iconv │ │ │ ├── debian │ │ │ │ ├── compat │ │ │ │ ├── docs │ │ │ │ ├── examples │ │ │ │ ├── rules │ │ │ │ ├── control │ │ │ │ └── changelog │ │ │ ├── .gitignore │ │ │ ├── fp.utf16.txt │ │ │ ├── fp.utf32.txt │ │ │ ├── fp.utf8.txt │ │ │ ├── makestr.lua │ │ │ ├── maketargz.sh │ │ │ └── uniopen.lua │ │ ├── luafilesystem │ │ │ ├── .gitignore │ │ │ ├── src │ │ │ │ ├── .gitignore │ │ │ │ ├── lfs.def │ │ │ │ └── lfs.h │ │ │ ├── vc6 │ │ │ │ ├── lfs.def │ │ │ │ └── luafilesystem.dsw │ │ │ ├── doc │ │ │ │ └── us │ │ │ │ │ └── luafilesystem.png │ │ │ ├── config.win │ │ │ ├── Makefile │ │ │ ├── Makefile.win │ │ │ ├── config │ │ │ ├── luafilesystem-scm-1.rockspec │ │ │ ├── appveyor.yml │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ └── README.md │ │ ├── lua-cjson │ │ │ ├── tests │ │ │ │ ├── types.json │ │ │ │ ├── octets-escaped.dat │ │ │ │ ├── README │ │ │ │ ├── numbers.json │ │ │ │ ├── example2.json │ │ │ │ ├── rfc-example1.json │ │ │ │ ├── rfc-example2.json │ │ │ │ ├── example3.json │ │ │ │ ├── genutf8.pl │ │ │ │ ├── example1.json │ │ │ │ └── example5.json │ │ │ ├── THANKS │ │ │ ├── lua │ │ │ │ ├── json2lua.lua │ │ │ │ └── lua2json.lua │ │ │ ├── fpconv.h │ │ │ ├── README.adoc │ │ │ └── LICENSE │ │ ├── pbc │ │ │ ├── test │ │ │ │ ├── float.proto │ │ │ │ ├── test.proto │ │ │ │ ├── array.c │ │ │ │ ├── readfile.h │ │ │ │ ├── test.c │ │ │ │ ├── addressbook.proto │ │ │ │ └── varint.c │ │ │ ├── .gitignore │ │ │ ├── pbc │ │ │ │ └── pbc-Prefix.pch │ │ │ ├── pbc.xcodeproj │ │ │ │ └── project.xcworkspace │ │ │ │ │ └── contents.xcworkspacedata │ │ │ ├── src │ │ │ │ ├── bootstrap.h │ │ │ │ ├── stringpool.h │ │ │ │ ├── pattern.h │ │ │ │ ├── varint.h │ │ │ │ ├── array.h │ │ │ │ ├── alloc.h │ │ │ │ └── map.h │ │ │ ├── binding │ │ │ │ ├── lua │ │ │ │ │ ├── Makefile │ │ │ │ │ ├── test2.lua │ │ │ │ │ └── test.lua │ │ │ │ └── lua53 │ │ │ │ │ ├── Makefile │ │ │ │ │ └── test.lua │ │ │ ├── Android.mk │ │ │ ├── pbc.sln │ │ │ └── license.txt │ │ ├── lpeg │ │ │ ├── lpeg-128.gif │ │ │ ├── lpprint.h │ │ │ └── lpcode.h │ │ ├── ip2region │ │ │ ├── ip2region.db │ │ │ ├── text.lua │ │ │ └── Makefile │ │ ├── lua │ │ │ ├── lua.hpp │ │ │ ├── README │ │ │ ├── lapi.h │ │ │ ├── lundump.h │ │ │ └── lprefix.h │ │ └── lua-md5 │ │ │ ├── md5.h │ │ │ ├── README │ │ │ ├── compat-5.2.h │ │ │ └── compat-5.2.c │ ├── lualib │ │ ├── compat10 │ │ │ ├── dns.lua │ │ │ ├── stm.lua │ │ │ ├── crypt.lua │ │ │ ├── snax.lua │ │ │ ├── cluster.lua │ │ │ ├── memory.lua │ │ │ ├── mongo.lua │ │ │ ├── mqueue.lua │ │ │ ├── mysql.lua │ │ │ ├── netpack.lua │ │ │ ├── profile.lua │ │ │ ├── redis.lua │ │ │ ├── sharemap.lua │ │ │ ├── socket.lua │ │ │ ├── datacenter.lua │ │ │ ├── multicast.lua │ │ │ ├── sharedata.lua │ │ │ ├── socketchannel.lua │ │ │ └── socketdriver.lua │ │ ├── skynet │ │ │ ├── datacenter.lua │ │ │ ├── harbor.lua │ │ │ ├── queue.lua │ │ │ └── service.lua │ │ ├── http │ │ │ └── url.lua │ │ ├── sprotoloader.lua │ │ ├── loader.lua │ │ └── md5.lua │ ├── lualib-src │ │ ├── sproto │ │ │ ├── README │ │ │ └── msvcint.h │ │ └── lua-seri.h │ ├── .DS_Store │ ├── test │ │ ├── sharemap.sp │ │ ├── testdeadloop.lua │ │ ├── testendless.lua │ │ ├── testharborlink.lua │ │ ├── testqueue.lua │ │ ├── testdns.lua │ │ ├── testservice │ │ │ ├── init.lua │ │ │ └── kvdb.lua │ │ ├── testterm.lua │ │ ├── testsharetable.lua │ │ ├── time.lua │ │ ├── testdatacenter.lua │ │ ├── testtimer.lua │ │ ├── testudp.lua │ │ ├── testmulticast2.lua │ │ ├── testmemlimit.lua │ │ ├── teststm.lua │ │ ├── testping.lua │ │ ├── testdeadcall.lua │ │ ├── testoverload.lua │ │ ├── testecho.lua │ │ ├── testresponse.lua │ │ ├── pingserver.lua │ │ ├── testmulticast.lua │ │ ├── testdatasheet.lua │ │ ├── testsm.lua │ │ ├── testhttp.lua │ │ └── testtimeout.lua │ ├── luaclib │ │ └── .DS_Store │ ├── cservice │ │ └── .DS_Store │ ├── examples │ │ ├── abort.lua │ │ ├── preload.lua │ │ ├── clustername.lua │ │ ├── main_mysql.lua │ │ ├── config.login │ │ ├── config_log │ │ ├── main_mongodb.lua │ │ ├── config.path │ │ ├── globallog.lua │ │ ├── login │ │ │ └── main.lua │ │ ├── config.c2 │ │ ├── config.c1 │ │ ├── config.mysql │ │ ├── config.mongodb │ │ ├── main_log.lua │ │ ├── config │ │ ├── protoloader.lua │ │ ├── config.mc │ │ ├── config.userlog │ │ ├── userlog.lua │ │ ├── main.lua │ │ ├── injectlaunch.lua │ │ ├── proto.lua │ │ ├── checkdeadloop.lua │ │ ├── cluster1.lua │ │ ├── simpledb.lua │ │ ├── simplemonitor.lua │ │ └── cluster2.lua │ ├── skynet.dSYM │ │ └── Contents │ │ │ ├── Resources │ │ │ └── DWARF │ │ │ │ └── skynet │ │ │ └── Info.plist │ ├── skynet-src │ │ ├── skynet_daemon.h │ │ ├── skynet_env.h │ │ ├── skynet_timer.h │ │ ├── skynet_monitor.h │ │ ├── skynet_log.h │ │ ├── luashrtbl.h │ │ ├── skynet_imp.h │ │ ├── atomic.h │ │ ├── socket_info.h │ │ ├── skynet_handle.h │ │ ├── skynet_harbor.h │ │ ├── malloc_hook.h │ │ ├── socket_poll.h │ │ ├── skynet_malloc.h │ │ ├── skynet_env.c │ │ ├── skynet_module.h │ │ └── skynet_monitor.c │ ├── service │ │ ├── cmemory.lua │ │ ├── service_cell.lua │ │ ├── console.lua │ │ ├── debug_agent.lua │ │ ├── dbg.lua │ │ └── clusterproxy.lua │ ├── platform.mk │ ├── LICENSE │ ├── testshell.sh │ └── README.md ├── .DS_Store ├── template │ ├── assets │ │ ├── view │ │ │ ├── item.html │ │ │ ├── footer.html │ │ │ ├── .DS_Store │ │ │ ├── system │ │ │ │ └── .DS_Store │ │ │ └── layout.html │ │ ├── .DS_Store │ │ └── config │ │ │ └── ip2region.data │ ├── .DS_Store │ ├── lualib │ │ ├── .DS_Store │ │ ├── api │ │ │ └── .DS_Store │ │ └── api_router.lua │ └── config │ │ └── config.test ├── bin │ └── .DS_Store ├── lualib │ ├── .DS_Store │ └── meiru │ │ ├── .DS_Store │ │ ├── role │ │ ├── modeler.lua │ │ └── moduler.lua │ │ ├── com │ │ ├── comfinish.lua │ │ ├── comhandle.lua │ │ ├── index.lua │ │ ├── cominit.lua │ │ ├── comheader.lua │ │ ├── com.lua │ │ ├── comcors.lua │ │ ├── compath.lua │ │ ├── comresponse.lua │ │ ├── comcookie.lua │ │ ├── combody.lua │ │ └── comsession.lua │ │ ├── node │ │ ├── static.lua │ │ └── root.lua │ │ ├── db │ │ └── mysqldbd.lua │ │ ├── util │ │ └── url.lua │ │ └── lib │ │ ├── emaild.lua │ │ ├── uuid.lua │ │ └── systemd.lua ├── service │ ├── .DS_Store │ └── meiru │ │ └── ip2regiond.lua └── config │ ├── config.main │ ├── config.header │ └── config.demo └── test ├── assets ├── view │ ├── item.html │ ├── .DS_Store │ ├── footer.html │ ├── system │ │ └── .DS_Store │ └── layout.html ├── .DS_Store └── config │ └── ip2region.data ├── lualib ├── .DS_Store ├── api │ └── .DS_Store └── api_router.lua └── config └── config.test /meiru/skynet/3rd/jemalloc/config.stamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/config.stamp.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/docs: -------------------------------------------------------------------------------- 1 | README 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | 3 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/examples: -------------------------------------------------------------------------------- 1 | test_iconv.lua 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/dns.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.dns" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/stm.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.stm" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/crypt.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.crypt" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/snax.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.snax" -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/junk_alloc.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/junk_free.c: -------------------------------------------------------------------------------- 1 | #include "junk.c" 2 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/cluster.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.cluster" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/memory.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.memory" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/mongo.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.db.mongo" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/mqueue.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.mqueue" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/mysql.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.db.mysql" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/netpack.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.netpack" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/profile.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.profile" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/redis.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.db.redis" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/sharemap.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.sharemap" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/socket.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.socket" -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/.gitignore: -------------------------------------------------------------------------------- 1 | *.lo 2 | *.o 3 | *.so 4 | *.tar.gz 5 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/datacenter.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.datacenter" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/multicast.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.multicast" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/sharedata.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.sharedata" -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/types.json: -------------------------------------------------------------------------------- 1 | { "array": [ 10, true, null ] } 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | %: 3 | dh $@ 4 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/socketchannel.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.socketchannel" -------------------------------------------------------------------------------- /meiru/skynet/lualib/compat10/socketdriver.lua: -------------------------------------------------------------------------------- 1 | return require "skynet.socketdriver" -------------------------------------------------------------------------------- /test/assets/view/item.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

<%= config.name .."-".. topic.title %>

-------------------------------------------------------------------------------- /meiru/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/VERSION: -------------------------------------------------------------------------------- 1 | 5.2.0-0-gb0b3e49a54ec29e32636f4577d9d5a896d67fd20 2 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/run_tests.sh: -------------------------------------------------------------------------------- 1 | $(dirname "$)")/scripts/gen_run_tests.py | bash 2 | -------------------------------------------------------------------------------- /meiru/skynet/lualib-src/sproto/README: -------------------------------------------------------------------------------- 1 | Check https://github.com/cloudwu/sproto for more 2 | -------------------------------------------------------------------------------- /meiru/template/assets/view/item.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

<%= config.name .."-".. topic.title %>

-------------------------------------------------------------------------------- /meiru/bin/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/bin/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/src/math.c: -------------------------------------------------------------------------------- 1 | #define MATH_C_ 2 | #include "test/jemalloc_test.h" 3 | -------------------------------------------------------------------------------- /meiru/lualib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/lualib/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/.DS_Store -------------------------------------------------------------------------------- /test/assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/assets/.DS_Store -------------------------------------------------------------------------------- /test/lualib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/lualib/.DS_Store -------------------------------------------------------------------------------- /meiru/service/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/service/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/msvc/test_threads/test_threads.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int test_threads(); 4 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/src/btalloc_0.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(0) 4 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/src/btalloc_1.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | btalloc_n_gen(1) 4 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/src/lfs.def: -------------------------------------------------------------------------------- 1 | LIBRARY lfs.dll 2 | VERSION 1.7 3 | EXPORTS 4 | luaopen_lfs 5 | -------------------------------------------------------------------------------- /meiru/skynet/test/sharemap.sp: -------------------------------------------------------------------------------- 1 | .foobar { 2 | x 0 : integer 3 | y 1 : integer 4 | s 2 : string 5 | } 6 | -------------------------------------------------------------------------------- /meiru/template/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/.DS_Store -------------------------------------------------------------------------------- /test/lualib/api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/lualib/api/.DS_Store -------------------------------------------------------------------------------- /test/assets/view/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/assets/view/.DS_Store -------------------------------------------------------------------------------- /meiru/lualib/meiru/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/lualib/meiru/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/float.proto: -------------------------------------------------------------------------------- 1 | message real { 2 | optional float f = 1; 3 | optional double d = 2; 4 | } 5 | -------------------------------------------------------------------------------- /meiru/skynet/luaclib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/luaclib/.DS_Store -------------------------------------------------------------------------------- /test/assets/view/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
elua come from skynetlua community
-------------------------------------------------------------------------------- /meiru/skynet/cservice/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/cservice/.DS_Store -------------------------------------------------------------------------------- /meiru/template/assets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/assets/.DS_Store -------------------------------------------------------------------------------- /meiru/template/lualib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/lualib/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/arena_reset_prof.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="prof:true,lg_prof_sample:0" 4 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lpeg/lpeg-128.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/lpeg/lpeg-128.gif -------------------------------------------------------------------------------- /meiru/template/assets/view/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
elua come from skynetlua community
-------------------------------------------------------------------------------- /meiru/template/lualib/api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/lualib/api/.DS_Store -------------------------------------------------------------------------------- /test/assets/config/ip2region.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/assets/config/ip2region.data -------------------------------------------------------------------------------- /test/assets/view/system/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/test/assets/view/system/.DS_Store -------------------------------------------------------------------------------- /meiru/template/assets/view/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/assets/view/.DS_Store -------------------------------------------------------------------------------- /meiru/skynet/3rd/ip2region/ip2region.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/ip2region/ip2region.db -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/fp.utf16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/lua-iconv/fp.utf16.txt -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/fp.utf32.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/lua-iconv/fp.utf32.txt -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/vc6/lfs.def: -------------------------------------------------------------------------------- 1 | LIBRARY lfs.dll 2 | DESCRIPTION "LuaFileSystem" 3 | VERSION 1.2 4 | EXPORTS 5 | luaopen_lfs 6 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/binshard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MALLOC_CONF="narenas:1,bin_shards:1-160:16|129-512:4|256-256:8" 4 | -------------------------------------------------------------------------------- /meiru/skynet/examples/abort.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | require "skynet.manager" -- import skynet.abort 3 | 4 | skynet.abort() 5 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/preload.lua: -------------------------------------------------------------------------------- 1 | -- This file will execute before every lua service start 2 | -- See config 3 | 4 | print("PRELOAD", ...) 5 | 6 | -------------------------------------------------------------------------------- /meiru/template/assets/config/ip2region.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/assets/config/ip2region.data -------------------------------------------------------------------------------- /meiru/template/assets/view/system/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/template/assets/view/system/.DS_Store -------------------------------------------------------------------------------- /meiru/lualib/meiru/role/modeler.lua: -------------------------------------------------------------------------------- 1 | 2 | local Modeler = class("Modeler") 3 | 4 | function Modeler:ctor(agent) 5 | 6 | end 7 | 8 | return Modeler 9 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/integration/smallocx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x${enable_fill}" = "x1" ] ; then 4 | export MALLOC_CONF="junk:false" 5 | fi 6 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/octets-escaped.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/lua-cjson/tests/octets-escaped.dat -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.sdf 3 | *.opensdf 4 | *.d 5 | *.o 6 | Debug 7 | Release 8 | build 9 | .DS_Store 10 | xcuserdata 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/doc/us/luafilesystem.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/3rd/luafilesystem/doc/us/luafilesystem.png -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/test.proto: -------------------------------------------------------------------------------- 1 | message at { 2 | optional int32 aa = 1; 3 | optional int32 bb = 2; 4 | optional string cc = 3; 5 | } 6 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/prof_log.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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/skynet.dSYM/Contents/Resources/DWARF/skynet: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skynetlua/meiru-skynet/HEAD/meiru/skynet/skynet.dSYM/Contents/Resources/DWARF/skynet -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/README: -------------------------------------------------------------------------------- 1 | These JSON examples were taken from the JSON website 2 | (http://json.org/example.html) and RFC 4627. 3 | 4 | Used with permission. 5 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/integration/slab_sizes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Some screwy-looking slab sizes. 4 | export MALLOC_CONF="slab_sizes:1-4096:17|100-200:1|128-128:2" 5 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/clustername.lua: -------------------------------------------------------------------------------- 1 | __nowaiting = true -- If you turn this flag off, cluster.call would block when node name is absent 2 | 3 | db = "127.0.0.1:2528" 4 | db2 = "127.0.0.1:2529" 5 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/numbers.json: -------------------------------------------------------------------------------- 1 | [ 0.110001, 2 | 0.12345678910111, 3 | 0.412454033640, 4 | 2.6651441426902, 5 | 2.718281828459, 6 | 3.1415926535898, 7 | 2.1406926327793 ] 8 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_daemon.h: -------------------------------------------------------------------------------- 1 | #ifndef skynet_daemon_h 2 | #define skynet_daemon_h 3 | 4 | int daemon_init(const char *pidfile); 5 | int daemon_exit(const char *pidfile); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/lualib-src/lua-seri.h: -------------------------------------------------------------------------------- 1 | #ifndef LUA_SERIALIZE_H 2 | #define LUA_SERIALIZE_H 3 | 4 | #include 5 | 6 | int luaseri_pack(lua_State *L); 7 | int luaseri_unpack(lua_State *L); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /test/lualib/api_router.lua: -------------------------------------------------------------------------------- 1 | local system = require "api.system" 2 | local meiru = require "meiru.meiru" 3 | 4 | local router = meiru.router() 5 | 6 | router.get('/api/system/:what', system.index) 7 | 8 | return router -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/bin/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | prefix=/usr/local 4 | exec_prefix=/usr/local 5 | libdir=${exec_prefix}/lib 6 | 7 | LD_PRELOAD=${libdir}/libjemalloc.so.2 8 | export LD_PRELOAD 9 | exec "$@" 10 | -------------------------------------------------------------------------------- /meiru/template/lualib/api_router.lua: -------------------------------------------------------------------------------- 1 | local system = require "api.system" 2 | local meiru = require "meiru.meiru" 3 | 4 | local router = meiru.router() 5 | 6 | router.get('/api/system/:what', system.index) 7 | 8 | return router -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/pbc/pbc-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'pbc' target in the 'pbc' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import "pbc.h" 8 | #endif 9 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/ip2region/text.lua: -------------------------------------------------------------------------------- 1 | local ip2region = require("ip2region") 2 | ip2region.init("ip2region.db") 3 | print(ip2region.find("1.2.176.224")) 4 | print(ip2region.ip2long("209.207.224.40")) 5 | print(ip2region.long2ip(3520061480)) -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/pbc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /meiru/skynet/test/testdeadloop.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local function dead_loop() 3 | while true do 4 | skynet.sleep(0) 5 | end 6 | end 7 | 8 | skynet.start(function() 9 | skynet.fork(dead_loop) 10 | end) 11 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_env.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_ENV_H 2 | #define SKYNET_ENV_H 3 | 4 | const char * skynet_getenv(const char *key); 5 | void skynet_setenv(const char *key, const char *value); 6 | 7 | void skynet_env_init(); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/doc/manpages.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/doc/manpages.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /meiru/skynet/examples/main_mysql.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | 4 | skynet.start(function() 5 | print("Main Server start") 6 | local console = skynet.newservice("testmysql") 7 | 8 | print("Main Server exit") 9 | skynet.exit() 10 | end) 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.login: -------------------------------------------------------------------------------- 1 | thread = 8 2 | logger = nil 3 | harbor = 0 4 | start = "main" 5 | bootstrap = "snlua bootstrap" -- The service for bootstrap 6 | luaservice = "./service/?.lua;./examples/login/?.lua" 7 | lualoader = "lualib/loader.lua" 8 | cpath = "./cservice/?.so" 9 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/bootstrap.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_BOOTSTRAP_H 2 | #define PROTOBUF_C_BOOTSTRAP_H 3 | 4 | #include "proto.h" 5 | #include "pbc.h" 6 | 7 | void _pbcB_init(struct pbc_env *); 8 | void _pbcB_register_fields(struct pbc_env *, pbc_array queue); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/THANKS: -------------------------------------------------------------------------------- 1 | The following people have helped with bug reports, testing and/or 2 | suggestions: 3 | 4 | - Louis-Philippe Perron (@loopole) 5 | - Ondřej Jirman 6 | - Steve Donovan 7 | - Zhang "agentzh" Yichun 8 | 9 | Thanks! 10 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/doc/html.xsl.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/doc/html.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config_log: -------------------------------------------------------------------------------- 1 | thread = 8 2 | mqueue = 256 3 | cpath = "./cservice/?.so" 4 | logger = nil 5 | harbor = 2 6 | address = "127.0.0.1:2527" 7 | master = "127.0.0.1:2013" 8 | start = "main_log" 9 | luaservice ="./service/?.lua;./test/?.lua;./examples/?.lua" 10 | snax = "./examples/?.lua;./test/?.lua" 11 | -------------------------------------------------------------------------------- /meiru/skynet/examples/main_mongodb.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | 4 | skynet.start(function() 5 | print("Main Server start") 6 | local console = skynet.newservice( 7 | "testmongodb", "127.0.0.1", 27017, "testdb", "test", "test" 8 | ) 9 | 10 | print("Main Server exit") 11 | skynet.exit() 12 | end) 13 | -------------------------------------------------------------------------------- /meiru/skynet/test/testendless.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | skynet.start(function() 4 | for i = 1, 1000000000 do -- very long loop 5 | if i%100000000 == 0 then 6 | print("Endless = ", skynet.stat "endless") 7 | print("Cost time = ", skynet.stat "time") 8 | end 9 | end 10 | skynet.exit() 11 | end) 12 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/example2.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "id": "file", 3 | "value": "File", 4 | "popup": { 5 | "menuitem": [ 6 | {"value": "New", "onclick": "CreateNewDoc()"}, 7 | {"value": "Open", "onclick": "OpenDoc()"}, 8 | {"value": "Close", "onclick": "CloseDoc()"} 9 | ] 10 | } 11 | }} 12 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/stringpool.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_STRINGPOOL_H 2 | #define PROTOBUF_C_STRINGPOOL_H 3 | 4 | struct _stringpool; 5 | 6 | struct _stringpool * _pbcS_new(void); 7 | void _pbcS_delete(struct _stringpool *pool); 8 | const char * _pbcS_build(struct _stringpool *pool, const char * str , int sz); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/role/moduler.lua: -------------------------------------------------------------------------------- 1 | 2 | local Moduler = class("Moduler") 3 | 4 | function Moduler:ctor(dispatcher, module_path) 5 | self.modules = {} 6 | end 7 | 8 | function Moduler:add_module(name, m) 9 | self.modules[name] = m 10 | end 11 | 12 | function Moduler:get_modules() 13 | return self.modules 14 | end 15 | 16 | return Moduler -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/binding/lua/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -O2 -fPIC -Wall 3 | LUADIR = /usr/local/include 4 | TARGET = protobuf.so 5 | 6 | .PHONY : all clean 7 | 8 | all : $(TARGET) 9 | 10 | $(TARGET) : pbc-lua.c 11 | $(CC) $(CFLAGS) -shared -o $@ -I../.. -I$(LUADIR) -L../../build $^ -lpbc 12 | 13 | clean : 14 | rm -f $(TARGET) 15 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.path: -------------------------------------------------------------------------------- 1 | root = "./" 2 | luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua;"..root.."test/?/init.lua" 3 | lualoader = root .. "lualib/loader.lua" 4 | lua_path = root.."lualib/?.lua;"..root.."lualib/?/init.lua" 5 | lua_cpath = root .. "luaclib/?.so" 6 | snax = root.."examples/?.lua;"..root.."test/?.lua" 7 | -------------------------------------------------------------------------------- /meiru/skynet/examples/globallog.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | require "skynet.manager" -- import skynet.register 3 | 4 | skynet.start(function() 5 | skynet.dispatch("lua", function(session, address, ...) 6 | print("[GLOBALLOG]", skynet.address(address), ...) 7 | end) 8 | skynet.register ".log" 9 | skynet.register "LOG" 10 | end) 11 | -------------------------------------------------------------------------------- /meiru/skynet/examples/login/main.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | skynet.start(function() 4 | local loginserver = skynet.newservice("logind") 5 | local gate = skynet.newservice("gated", loginserver) 6 | 7 | skynet.call(gate, "lua", "open" , { 8 | port = 8888, 9 | maxclient = 64, 10 | servername = "sample", 11 | }) 12 | end) 13 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/integration/malloc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_zero_alloc) { 4 | void *res = malloc(0); 5 | assert(res); 6 | size_t usable = malloc_usable_size(res); 7 | assert(usable > 0); 8 | free(res); 9 | } 10 | TEST_END 11 | 12 | int 13 | main(void) { 14 | return test( 15 | test_zero_alloc); 16 | } 17 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.c2: -------------------------------------------------------------------------------- 1 | thread = 8 2 | logger = nil 3 | harbor = 0 4 | start = "cluster2" 5 | bootstrap = "snlua bootstrap" -- The service for bootstrap 6 | luaservice = "./service/?.lua;./test/?.lua;./examples/?.lua" 7 | lualoader = "lualib/loader.lua" 8 | cpath = "./cservice/?.so" 9 | cluster = "./examples/clustername.lua" 10 | snax = "./test/?.lua" 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/fp.utf8.txt: -------------------------------------------------------------------------------- 1 | Ao longe, ao luar 2 | No rio uma vela 3 | Serena a passar, 4 | Que é que me revela 5 | 6 | Não sei, mas mue ser 7 | Tornou-se-me estranho, 8 | E eu sonho sem ver 9 | Os sonhos que tenho. 10 | 11 | Que angústia me enlaça? 12 | Que amor não se explica? 13 | É a vela que passa 14 | Na noite que fica 15 | 16 | -- Fernando Pessoa 17 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua/README: -------------------------------------------------------------------------------- 1 | This is a modify version of lua 5.3.2 (http://www.lua.org/ftp/lua-5.3.2.tar.gz) . 2 | 3 | For detail , 4 | Shared Proto : http://lua-users.org/lists/lua-l/2014-03/msg00489.html 5 | Shared short string table : http://blog.codingnow.com/2015/08/lua_vm_share_string.html 6 | Signal for debug use : http://blog.codingnow.com/2015/03/skynet_signal.html 7 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/binding/lua53/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -O2 -fPIC -Wall 3 | # LUADIR = /usr/local/include 4 | LUADIR = ../../../lua 5 | TARGET = protobuf.so 6 | 7 | .PHONY : all clean 8 | 9 | all : $(TARGET) 10 | 11 | $(TARGET) : pbc-lua53.c 12 | $(CC) $(CFLAGS) -shared -o $@ -I../.. -I$(LUADIR) -L../../build $^ -lpbc 13 | 14 | clean : 15 | rm -f $(TARGET) 16 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comfinish.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | ---------------------------------------------- 4 | --ComFinish 5 | ---------------------------------------------- 6 | local ComFinish = class("ComFinish", Com) 7 | 8 | function ComFinish:ctor() 9 | end 10 | 11 | function ComFinish:match(req, res) 12 | 13 | end 14 | 15 | 16 | return ComFinish 17 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/node/static.lua: -------------------------------------------------------------------------------- 1 | local Node = include("node", ...) 2 | 3 | 4 | local function create_node_static(path, static_dir) 5 | local node = Node.new("node_static") 6 | node:set_method("get") 7 | node:set_path(path) 8 | node:open_terminal() 9 | node:add_com("ComStatic", static_dir) 10 | return node 11 | end 12 | 13 | return create_node_static -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_timer.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_TIMER_H 2 | #define SKYNET_TIMER_H 3 | 4 | #include 5 | 6 | int skynet_timeout(uint32_t handle, int time, int session); 7 | void skynet_updatetime(void); 8 | uint32_t skynet_starttime(void); 9 | uint64_t skynet_thread_time(void); // for profile, in micro second 10 | 11 | void skynet_timer_init(void); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/rfc-example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "Image": { 3 | "Width": 800, 4 | "Height": 600, 5 | "Title": "View from 15th Floor", 6 | "Thumbnail": { 7 | "Url": "http://www.example.com/image/481989943", 8 | "Height": 125, 9 | "Width": "100" 10 | }, 11 | "IDs": [116, 943, 234, 38793] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/lua/json2lua.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | -- usage: json2lua.lua [json_file] 4 | -- 5 | -- Eg: 6 | -- echo '[ "testing" ]' | ./json2lua.lua 7 | -- ./json2lua.lua test.json 8 | 9 | local json = require "cjson" 10 | local util = require "cjson.util" 11 | 12 | local json_text = util.file_load(arg[1]) 13 | local t = json.decode(json_text) 14 | print(util.serialise_value(t)) 15 | -------------------------------------------------------------------------------- /meiru/skynet/test/testharborlink.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local harbor = require "skynet.harbor" 3 | 4 | skynet.start(function() 5 | print("wait for harbor 2") 6 | print("run skynet examples/config_log please") 7 | harbor.connect(2) 8 | print("harbor 2 connected") 9 | print("LOG =", skynet.address(harbor.queryname "LOG")) 10 | harbor.link(2) 11 | print("disconnected") 12 | end) 13 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/ip2region/Makefile: -------------------------------------------------------------------------------- 1 | all : ip2region.so 2 | 3 | LUA_INC ?= ../lua 4 | 5 | SRC_INC ?= ./ 6 | 7 | SHARED := -fPIC --shared 8 | CFLAGS := -g -O2 -Wall -lstdc++ -std=c++0x -I. 9 | 10 | lua-ip2region-scr = \ 11 | ip2region.cpp \ 12 | ip2region.c 13 | 14 | ip2region.so : $(lua-ip2region-scr) 15 | gcc $(CFLAGS) $(SHARED) -I$(LUA_INC) -I$(SRC_INC) -o $@ $^ 16 | 17 | clean : 18 | rm -rf *.so 19 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.c1: -------------------------------------------------------------------------------- 1 | thread = 8 2 | logger = nil 3 | harbor = 0 4 | start = "cluster1" 5 | bootstrap = "snlua bootstrap" -- The service for bootstrap 6 | luaservice = "./service/?.lua;./test/?.lua;./examples/?.lua" 7 | lualoader = "lualib/loader.lua" 8 | cpath = "./cservice/?.so" 9 | -- use cluster.reload instead, see cluster1.lua 10 | -- cluster = "./examples/clustername.lua" 11 | snax = "./test/?.lua" 12 | -------------------------------------------------------------------------------- /meiru/skynet/service/cmemory.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local memory = require "skynet.memory" 3 | 4 | memory.dumpinfo() 5 | --memory.dump() 6 | local info = memory.info() 7 | for k,v in pairs(info) do 8 | print(string.format(":%08x %gK",k,v/1024)) 9 | end 10 | 11 | print("Total memory:", memory.total()) 12 | print("Total block:", memory.block()) 13 | 14 | skynet.start(function() skynet.exit() end) 15 | -------------------------------------------------------------------------------- /meiru/skynet/test/testqueue.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local snax = require "skynet.snax" 3 | 4 | skynet.start(function() 5 | local ps = snax.uniqueservice ("pingserver", "test queue") 6 | for i=1, 10 do 7 | ps.post.sleep(true,i*10) 8 | ps.post.hello() 9 | end 10 | for i=1, 10 do 11 | ps.post.sleep(false,i*10) 12 | ps.post.hello() 13 | end 14 | 15 | skynet.exit() 16 | end) 17 | 18 | 19 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-md5/md5.h: -------------------------------------------------------------------------------- 1 | /** 2 | * $Id: md5.h,v 1.2 2006/03/03 15:04:49 tomas Exp $ 3 | * Cryptographic module for Lua. 4 | * @author Roberto Ierusalimschy 5 | */ 6 | 7 | 8 | #ifndef md5_h 9 | #define md5_h 10 | 11 | #include 12 | 13 | 14 | #define HASHSIZE 16 15 | 16 | void md5 (const char *message, long len, char *output); 17 | int luaopen_md5_core (lua_State *L); 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.mysql: -------------------------------------------------------------------------------- 1 | root = "./" 2 | thread = 8 3 | logger = nil 4 | harbor = 0 5 | start = "main_mysql" -- main script 6 | bootstrap = "snlua bootstrap" -- The service for bootstrap 7 | luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua" 8 | lualoader = "lualib/loader.lua" 9 | snax = root.."examples/?.lua;"..root.."test/?.lua" 10 | cpath = root.."cservice/?.so" 11 | -- daemon = "./skynet.pid" 12 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.mongodb: -------------------------------------------------------------------------------- 1 | root = "./" 2 | thread = 8 3 | logger = nil 4 | harbor = 0 5 | start = "main_mongodb" -- main script 6 | bootstrap = "snlua bootstrap" -- The service for bootstrap 7 | luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua" 8 | lualoader = "lualib/loader.lua" 9 | snax = root.."examples/?.lua;"..root.."test/?.lua" 10 | cpath = root.."cservice/?.so" 11 | -- daemon = "./skynet.pid" 12 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_MONITOR_H 2 | #define SKYNET_MONITOR_H 3 | 4 | #include 5 | 6 | struct skynet_monitor; 7 | 8 | struct skynet_monitor * skynet_monitor_new(); 9 | void skynet_monitor_delete(struct skynet_monitor *); 10 | void skynet_monitor_trigger(struct skynet_monitor *, uint32_t source, uint32_t destination); 11 | void skynet_monitor_check(struct skynet_monitor *); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-md5/README: -------------------------------------------------------------------------------- 1 | MD5 - Cryptographic Library for Lua 2 | Copyright 2003 PUC-Rio 3 | http://www.keplerproject.org/md5 4 | 5 | MD5 offers basic cryptographic facilities for Lua 5.1: a hash (digest) 6 | function, a pair crypt/decrypt based on MD5 and CFB, and a pair crypt/decrypt based 7 | on DES with 56-bit keys. 8 | 9 | MD5 current version is 1.1.2. 10 | 11 | This version is copy from https://github.com/keplerproject/md5 12 | 13 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-md5/compat-5.2.h: -------------------------------------------------------------------------------- 1 | #if !defined LUA_VERSION_NUM 2 | /* Lua 5.0 */ 3 | #define luaL_Reg luaL_reg 4 | 5 | #define luaL_addchar(B,c) \ 6 | ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ 7 | (*(B)->p++ = (char)(c))) 8 | #endif 9 | 10 | #if LUA_VERSION_NUM==501 11 | /* Lua 5.1 */ 12 | #define lua_rawlen lua_objlen 13 | #endif 14 | 15 | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); 16 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comhandle.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | ---------------------------------------------- 4 | --ComHandle 5 | ---------------------------------------------- 6 | local ComHandle = class("ComHandle", Com) 7 | 8 | function ComHandle:ctor(handle) 9 | assert(handle) 10 | self.handle = handle 11 | end 12 | 13 | function ComHandle:match(req, res) 14 | return self.handle(req, res) 15 | end 16 | 17 | return ComHandle 18 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/jemalloc.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=/usr/local 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 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: 5.2.0_0 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -ljemalloc${install_suffix} 13 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/skynet/datacenter.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local datacenter = {} 4 | 5 | function datacenter.get(...) 6 | return skynet.call("DATACENTER", "lua", "QUERY", ...) 7 | end 8 | 9 | function datacenter.set(...) 10 | return skynet.call("DATACENTER", "lua", "UPDATE", ...) 11 | end 12 | 13 | function datacenter.wait(...) 14 | return skynet.call("DATACENTER", "lua", "WAIT", ...) 15 | end 16 | 17 | return datacenter 18 | 19 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/db/mysqldbd.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | 4 | local _mysqldbd 5 | skynet.fork(function() 6 | _mysqldbd = skynet.uniqueservice("meiru/mysqldbd") 7 | end) 8 | 9 | 10 | local mysqldb = {} 11 | 12 | setmetatable(mysqldb, { __index = function(t,cmd) 13 | local f = function(...) 14 | return skynet.call(_mysqldbd, "lua", cmd, ...) 15 | end 16 | t[cmd] = f 17 | return f 18 | end}) 19 | 20 | 21 | return mysqldb -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/makestr.lua: -------------------------------------------------------------------------------- 1 | 2 | local fp = assert(io.open(arg[1], "rb")) 3 | local str = assert(fp:read("*a")) 4 | fp:close() 5 | 6 | local i 7 | local c = 0 8 | local ostr = "local xxxxxxxxxxx = \"" 9 | for i = 1, string.len(str) do 10 | ostr = ostr .. "\\" .. string.byte(string.sub(str, i, i+1)) 11 | if string.len(ostr) > 72 then 12 | io.write(ostr .. "\"\n") 13 | ostr = ".. \"" 14 | end 15 | end 16 | io.write(ostr .. "\"\n") 17 | 18 | 19 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_log.h: -------------------------------------------------------------------------------- 1 | #ifndef skynet_log_h 2 | #define skynet_log_h 3 | 4 | #include "skynet_env.h" 5 | #include "skynet.h" 6 | 7 | #include 8 | #include 9 | 10 | FILE * skynet_log_open(struct skynet_context * ctx, uint32_t handle); 11 | void skynet_log_close(struct skynet_context * ctx, FILE *f, uint32_t handle); 12 | void skynet_log_output(FILE *f, uint32_t source, int type, int session, void * buffer, size_t sz); 13 | 14 | #endif -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/index.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | local names = { 4 | "com", 5 | "combody", 6 | "comcookie", 7 | "comcsrf", 8 | "comcors", 9 | "comfinish", 10 | 11 | "comhandle", 12 | "comheader", 13 | "cominit", 14 | "compath", 15 | "comrender", 16 | 17 | "comresponse", 18 | "comsession", 19 | "comstatic" 20 | } 21 | local models = {} 22 | for _,name in ipairs(names) do 23 | local model = include(name, ...) 24 | models[model.__cname] = model 25 | end 26 | return models 27 | -------------------------------------------------------------------------------- /meiru/skynet/examples/main_log.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local harbor = require "skynet.harbor" 3 | require "skynet.manager" -- import skynet.monitor 4 | 5 | local function monitor_master() 6 | harbor.linkmaster() 7 | print("master is down") 8 | skynet.exit() 9 | end 10 | 11 | skynet.start(function() 12 | print("Log server start") 13 | skynet.monitor "simplemonitor" 14 | local log = skynet.newservice("globallog") 15 | skynet.fork(monitor_master) 16 | end) 17 | 18 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/luashrtbl.h: -------------------------------------------------------------------------------- 1 | #ifndef LUA_SHORT_STRING_TABLE_H 2 | #define LUA_SHORT_STRING_TABLE_H 3 | 4 | #include "lstring.h" 5 | 6 | // If you use modified lua, this macro would be defined in lstring.h 7 | #ifndef ENABLE_SHORT_STRING_TABLE 8 | 9 | static inline int luaS_shrinfo(lua_State *L) { return 0; } 10 | static inline void luaS_initshr() {} 11 | static inline void luaS_exitshr() {} 12 | static inline void luaS_expandshr(int n) {} 13 | 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/maketargz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PACKAGE=lua-iconv 4 | VERSION=7 5 | 6 | DIRNAME=$PACKAGE-$VERSION 7 | TGZNAME=$DIRNAME.tar.gz 8 | 9 | rm -f $TGZNAME 10 | mkdir $DIRNAME 11 | 12 | cp -r debian $DIRNAME/ 13 | #rm -rf $DIRNAME/debian/.svn 14 | 15 | cp -r COPYING Makefile README luaiconv.c test_iconv.lua $DIRNAME 16 | 17 | tar -czf $TGZNAME $DIRNAME 18 | 19 | #cd $DIRNAME dpkg-buildpackage -rfakeroot 20 | #cd .. 21 | 22 | rm -rf $DIRNAME 23 | tar -tzf $TGZNAME 24 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/doc/stylesheet.xsl: -------------------------------------------------------------------------------- 1 | 2 | ansi 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/src/test_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 (*test_hooks_arena_new_hook)() = NULL; 10 | 11 | JEMALLOC_EXPORT 12 | void (*test_hooks_libc_hook)() = NULL; 13 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/include/test/jemalloc_test_defs.h: -------------------------------------------------------------------------------- 1 | /* test/include/test/jemalloc_test_defs.h. Generated from jemalloc_test_defs.h.in by configure. */ 2 | #include "jemalloc/internal/jemalloc_internal_defs.h" 3 | #include "jemalloc/internal/jemalloc_internal_decls.h" 4 | 5 | /* 6 | * For use by SFMT. configure.ac doesn't actually define HAVE_SSE2 because its 7 | * dependencies are notoriously unportable in practice. 8 | */ 9 | /* #undef HAVE_SSE2 */ 10 | /* #undef HAVE_ALTIVEC */ 11 | -------------------------------------------------------------------------------- /test/config/config.test: -------------------------------------------------------------------------------- 1 | --导入meiru的配置表文件 2 | include "../../meiru/config/config.main" 3 | 4 | ---------------------------------------------------- 5 | --test项目配置 6 | ---------------------------------------------------- 7 | test_path = current_path 8 | lua_path = lua_path .. test_path .. "lualib/?.lua;" 9 | 10 | --ip查询地址数据库 11 | ip2region = test_path.."assets/config/ip2region.data" 12 | 13 | --设置debug模式,上线需要注释 14 | debug = 1 15 | service_http = "app" 16 | http_port = 8080 17 | service_num = 1 18 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config: -------------------------------------------------------------------------------- 1 | include "config.path" 2 | 3 | -- preload = "./examples/preload.lua" -- run preload.lua before every lua service run 4 | thread = 8 5 | logger = nil 6 | logpath = "." 7 | harbor = 1 8 | address = "127.0.0.1:2526" 9 | master = "127.0.0.1:2013" 10 | start = "main" -- main script 11 | bootstrap = "snlua bootstrap" -- The service for bootstrap 12 | standalone = "0.0.0.0:2013" 13 | -- snax_interface_g = "snax_g" 14 | cpath = root.."cservice/?.so" 15 | -- daemon = "./skynet.pid" 16 | -------------------------------------------------------------------------------- /meiru/skynet/test/testdns.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local dns = require "skynet.dns" 3 | 4 | local resolve_list = { 5 | "github.com", 6 | "stackoverflow.com", 7 | "lua.com", 8 | } 9 | 10 | skynet.start(function() 11 | -- you can specify the server like dns.server("8.8.4.4", 53) 12 | for _ , name in ipairs(resolve_list) do 13 | local ip, ips = dns.resolve(name) 14 | for k,v in ipairs(ips) do 15 | print(name,v) 16 | end 17 | skynet.sleep(500) -- sleep 5 sec 18 | end 19 | end) 20 | -------------------------------------------------------------------------------- /meiru/template/config/config.test: -------------------------------------------------------------------------------- 1 | --导入meiru的配置表文件 2 | include "../../meiru/config/config.main" 3 | 4 | ---------------------------------------------------- 5 | --test项目配置 6 | ---------------------------------------------------- 7 | test_path = current_path 8 | lua_path = lua_path .. test_path .. "lualib/?.lua;" 9 | 10 | --ip查询地址数据库 11 | ip2region = test_path.."assets/config/ip2region.data" 12 | 13 | --设置debug模式,上线需要注释 14 | debug = 1 15 | service_http = "app" 16 | http_port = 8080 17 | service_num = 1 18 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/lua/lua2json.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | -- usage: lua2json.lua [lua_file] 4 | -- 5 | -- Eg: 6 | -- echo '{ "testing" }' | ./lua2json.lua 7 | -- ./lua2json.lua test.lua 8 | 9 | local json = require "cjson" 10 | local util = require "cjson.util" 11 | 12 | local env = { 13 | json = { null = json.null }, 14 | null = json.null 15 | } 16 | 17 | local t = util.run_script("data = " .. util.file_load(arg[1]), env) 18 | print(json.encode(t.data)) 19 | 20 | -- vi:ai et sw=4 ts=4: 21 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/config.win: -------------------------------------------------------------------------------- 1 | # Installation directories 2 | # System's libraries directory (where binary libraries are installed) 3 | LUA_LIBDIR= "c:\lua5.1" 4 | 5 | # Lua includes directory 6 | LUA_INC= "c:\lua5.1\include" 7 | 8 | # Lua library 9 | LUA_LIB= "c:\lua5.1\lua5.1.lib" 10 | 11 | LIBNAME= $T.dll 12 | 13 | # Compilation directives 14 | WARN= /O2 15 | INCS= /I$(LUA_INC) 16 | CFLAGS= /MD $(WARN) $(INCS) 17 | CC= cl 18 | 19 | # $Id: config.win,v 1.7 2008/03/25 17:39:29 mascarenhas Exp $ 20 | -------------------------------------------------------------------------------- /meiru/config/config.main: -------------------------------------------------------------------------------- 1 | include "config.header" 2 | 3 | -- 预加载文件 4 | preload = meiru_path .. "lualib/meiru/preload/__preload.lua" 5 | 6 | --------------------------------------------------------------------- 7 | -- 启动配置 8 | --------------------------------------------------------------------- 9 | thread = 8 10 | harbor = 0 11 | bootstrap = "snlua bootstrap" 12 | --daemon = "./remote.pid" 13 | --logger = "./log/test.log" 14 | logpath = "." 15 | start = "meiru/main" 16 | maxclient = 20480 17 | 18 | 19 | -------------------------------------------------------------------------------- /meiru/skynet/examples/protoloader.lua: -------------------------------------------------------------------------------- 1 | -- module proto as examples/proto.lua 2 | package.path = "./examples/?.lua;" .. package.path 3 | 4 | local skynet = require "skynet" 5 | local sprotoparser = require "sprotoparser" 6 | local sprotoloader = require "sprotoloader" 7 | local proto = require "proto" 8 | 9 | skynet.start(function() 10 | sprotoloader.save(proto.c2s, 1) 11 | sprotoloader.save(proto.s2c, 2) 12 | -- don't call skynet.exit() , because sproto.core may unload and the global slot become invalid 13 | end) 14 | -------------------------------------------------------------------------------- /meiru/skynet/test/testservice/init.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local kvdb = require "kvdb" 3 | 4 | local function dbname(i) 5 | return "db"..i 6 | end 7 | skynet.start(function() 8 | for i=1,10 do 9 | kvdb.new(dbname(i)) 10 | end 11 | local idx=1 12 | for i=1,10 do 13 | local db=dbname(i) 14 | kvdb.set(db,"A",idx) 15 | idx=idx+1 16 | kvdb.set(db,"B",idx) 17 | idx=idx+1 18 | end 19 | for i=1,10 do 20 | local db=dbname(i) 21 | print(db,kvdb.get(db,"A"),kvdb.get(db,"B")) 22 | end 23 | end) 24 | -------------------------------------------------------------------------------- /meiru/skynet/test/testterm.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local function term() 4 | skynet.error("Sleep one second, and term the call to UNEXIST") 5 | skynet.sleep(100) 6 | local self = skynet.self() 7 | skynet.send(skynet.self(), "debug", "TERM", "UNEXIST") 8 | end 9 | 10 | skynet.start(function() 11 | skynet.fork(term) 12 | skynet.error("call an unexist named service UNEXIST, may block") 13 | pcall(skynet.call, "UNEXIST", "lua", "test") 14 | skynet.error("unblock the unexisted service call") 15 | end) 16 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/cominit.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | ---------------------------------------------- 4 | --ComInit 5 | ---------------------------------------------- 6 | local ComInit = class("ComInit", Com) 7 | 8 | function ComInit:ctor() 9 | end 10 | 11 | function ComInit:match(req, res) 12 | if req.app.get('x-powered-by') then 13 | res.set_header('X-Powered-By', 'MeiRu') 14 | end 15 | res.set_header('server', 'MeiRu/1.0.0') 16 | res.set_header('accept-ranges', 'bytes') 17 | end 18 | 19 | return ComInit 20 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_imp.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_IMP_H 2 | #define SKYNET_IMP_H 3 | 4 | struct skynet_config { 5 | int thread; 6 | int harbor; 7 | int profile; 8 | const char * daemon; 9 | const char * module_path; 10 | const char * bootstrap; 11 | const char * logger; 12 | const char * logservice; 13 | }; 14 | 15 | #define THREAD_WORKER 0 16 | #define THREAD_MAIN 1 17 | #define THREAD_SOCKET 2 18 | #define THREAD_TIMER 3 19 | #define THREAD_MONITOR 4 20 | 21 | void skynet_start(struct skynet_config * config); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := pbc 6 | 7 | LOCAL_MODULE_FILENAME := libpbc 8 | 9 | LOCAL_SRC_FILES := \ 10 | src/alloc.c \ 11 | src/array.c \ 12 | src/bootstrap.c \ 13 | src/context.c \ 14 | src/decode.c \ 15 | src/map.c \ 16 | src/pattern.c \ 17 | src/proto.c \ 18 | src/register.c \ 19 | src/rmessage.c \ 20 | src/stringpool.c \ 21 | src/varint.c \ 22 | src/wmessage.c \ 23 | 24 | 25 | 26 | LOCAL_C_INCLUDES+= src\ 27 | 28 | 29 | include $(BUILD_STATIC_LIBRARY) 30 | -------------------------------------------------------------------------------- /meiru/skynet/test/testsharetable.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local sharetable = require "skynet.sharetable" 3 | 4 | skynet.start(function() 5 | -- You can also use sharetable.loadfile / sharetable.loadstring 6 | sharetable.loadtable ("test", { x=1,y={ 'hello world' },['hello world'] = true }) 7 | local t = sharetable.query("test") 8 | for k,v in pairs(t) do 9 | print(k,v) 10 | end 11 | sharetable.loadstring ("test", "return { ... }", 1,2,3) 12 | local t = sharetable.query("test") 13 | for k,v in pairs(t) do 14 | print(k,v) 15 | end 16 | end) 17 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | /* 10 | * When reuse (and split) an active extent, (1U << opt_lg_extent_max_active_fit) 11 | * is the max ratio between the size of the active extent and the new extent. 12 | */ 13 | #define LG_EXTENT_MAX_ACTIVE_FIT_DEFAULT 6 14 | 15 | #endif /* JEMALLOC_INTERNAL_EXTENT_TYPES_H */ 16 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/array.c: -------------------------------------------------------------------------------- 1 | #include "pbc.h" 2 | #include "alloc.h" 3 | #include "array.h" 4 | 5 | #include 6 | 7 | int 8 | main() 9 | { 10 | pbc_array array; 11 | pbc_var v; 12 | 13 | _pbcA_open(array); 14 | 15 | int i ; 16 | 17 | for (i=0;i<100;i++) { 18 | v->real = (double)i; 19 | printf("push %d\n",i); 20 | _pbcA_push(array, v); 21 | } 22 | 23 | int s = pbc_array_size(array); 24 | 25 | for (i=0;ireal); 28 | } 29 | 30 | _pbcA_close(array); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/readfile.h: -------------------------------------------------------------------------------- 1 | #ifndef readfile_h 2 | #define readfile_h 3 | 4 | #include 5 | #include 6 | 7 | static void 8 | read_file (const char *filename , struct pbc_slice *slice) { 9 | FILE *f = fopen(filename, "rb"); 10 | if (f == NULL) { 11 | slice->buffer = NULL; 12 | slice->len = 0; 13 | return; 14 | } 15 | fseek(f,0,SEEK_END); 16 | slice->len = ftell(f); 17 | fseek(f,0,SEEK_SET); 18 | slice->buffer = malloc(slice->len); 19 | if (fread(slice->buffer, 1 , slice->len , f) == 0) 20 | exit(1); 21 | fclose(f); 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/msvc_compat/C99/stdbool.h: -------------------------------------------------------------------------------- 1 | #ifndef stdbool_h 2 | #define stdbool_h 3 | 4 | #include 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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/integration/cpp/basic.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "test/jemalloc_test.h" 3 | 4 | TEST_BEGIN(test_basic) { 5 | auto foo = new long(4); 6 | assert_ptr_not_null(foo, "Unexpected new[] failure"); 7 | delete foo; 8 | // Test nullptr handling. 9 | foo = nullptr; 10 | delete foo; 11 | 12 | auto bar = new long; 13 | assert_ptr_not_null(bar, "Unexpected new failure"); 14 | delete bar; 15 | // Test nullptr handling. 16 | bar = nullptr; 17 | delete bar; 18 | } 19 | TEST_END 20 | 21 | int 22 | main() { 23 | return test( 24 | test_basic); 25 | } 26 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.mc: -------------------------------------------------------------------------------- 1 | root = "./" 2 | thread = 8 3 | logger = nil 4 | harbor = 2 5 | address = "127.0.0.1:2527" 6 | master = "127.0.0.1:2013" 7 | start = "testmulticast2" -- main script 8 | bootstrap = "snlua bootstrap" -- The service for bootstrap 9 | --standalone = "0.0.0.0:2013" 10 | luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua" 11 | lualoader = "lualib/loader.lua" 12 | -- preload = "./examples/preload.lua" -- run preload.lua before every lua service run 13 | snax = root.."examples/?.lua;"..root.."test/?.lua" 14 | cpath = root.."cservice/?.so" 15 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.36 2009/09/21 17:02:44 mascarenhas Exp $ 2 | 3 | T= lfs 4 | 5 | CONFIG= ./config 6 | 7 | include $(CONFIG) 8 | 9 | SRCS= src/$T.c 10 | OBJS= src/$T.o 11 | 12 | lib: src/lfs.so 13 | 14 | src/lfs.so: $(OBJS) 15 | MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) $(LIB_OPTION) -o src/lfs.so $(OBJS) 16 | 17 | test: lib 18 | LUA_CPATH=./src/?.so lua tests/test.lua 19 | 20 | install: 21 | mkdir -p $(DESTDIR)$(LUA_LIBDIR) 22 | cp src/lfs.so $(DESTDIR)$(LUA_LIBDIR) 23 | 24 | clean: 25 | rm -f src/lfs.so $(OBJS) 26 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/bin_types.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BIN_TYPES_H 2 | #define JEMALLOC_INTERNAL_BIN_TYPES_H 3 | 4 | #include "jemalloc/internal/sc.h" 5 | 6 | #define BIN_SHARDS_MAX (1 << EXTENT_BITS_BINSHARD_WIDTH) 7 | #define N_BIN_SHARDS_DEFAULT 1 8 | 9 | /* Used in TSD static initializer only. Real init in arena_bind(). */ 10 | #define TSD_BINSHARDS_ZERO_INITIALIZER {{UINT8_MAX}} 11 | 12 | typedef struct tsd_binshards_s tsd_binshards_t; 13 | struct tsd_binshards_s { 14 | uint8_t binshard[SC_NBINS]; 15 | }; 16 | 17 | #endif /* JEMALLOC_INTERNAL_BIN_TYPES_H */ 18 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/pattern.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_PATTERN_H 2 | #define PROTOBUF_C_PATTERN_H 3 | 4 | #include "pbc.h" 5 | #include "context.h" 6 | #include "array.h" 7 | 8 | struct _pattern_field { 9 | int id; 10 | int offset; 11 | int ptype; 12 | int ctype; 13 | int label; 14 | pbc_var defv; 15 | }; 16 | 17 | struct pbc_pattern { 18 | struct pbc_env * env; 19 | int count; 20 | struct _pattern_field f[1]; 21 | }; 22 | 23 | struct pbc_pattern * _pbcP_new(struct pbc_env * env, int n); 24 | int _pbcP_unpack_packed(uint8_t *buffer, int size, int ptype, pbc_array array); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comheader.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | ---------------------------------------------- 4 | --ComHeader 5 | ---------------------------------------------- 6 | local ComHeader = class("ComHeader", Com) 7 | 8 | function ComHeader:ctor() 9 | 10 | end 11 | 12 | function ComHeader:match(req, res) 13 | local header = {} 14 | for k,v in pairs(req.rawheader) do 15 | k = string.lower(k) 16 | if k == 'user-agent' or k == 'content-type' then 17 | v = string.lower(v) 18 | end 19 | header[k] = v 20 | end 21 | req.header = header 22 | end 23 | 24 | return ComHeader 25 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/rfc-example2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "precision": "zip", 4 | "Latitude": 37.7668, 5 | "Longitude": -122.3959, 6 | "Address": "", 7 | "City": "SAN FRANCISCO", 8 | "State": "CA", 9 | "Zip": "94107", 10 | "Country": "US" 11 | }, 12 | { 13 | "precision": "zip", 14 | "Latitude": 37.371991, 15 | "Longitude": -122.026020, 16 | "Address": "", 17 | "City": "SUNNYVALE", 18 | "State": "CA", 19 | "Zip": "94085", 20 | "Country": "US" 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /meiru/skynet/examples/config.userlog: -------------------------------------------------------------------------------- 1 | root = "./" 2 | thread = 8 3 | logger = "userlog" 4 | logservice = "snlua" 5 | logpath = "." 6 | harbor = 0 7 | start = "main" -- main script 8 | bootstrap = "snlua bootstrap" -- The service for bootstrap 9 | luaservice = root.."service/?.lua;"..root.."test/?.lua;"..root.."examples/?.lua" 10 | lualoader = "lualib/loader.lua" 11 | -- preload = "./examples/preload.lua" -- run preload.lua before every lua service run 12 | snax = root.."examples/?.lua;"..root.."test/?.lua" 13 | -- snax_interface_g = "snax_g" 14 | cpath = root.."cservice/?.so" 15 | -- daemon = "./skynet.pid" 16 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/jemalloc_rename.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | public_symbols_txt=$1 4 | 5 | cat < 5 | 6 | struct longlong { 7 | uint32_t low; 8 | uint32_t hi; 9 | }; 10 | 11 | int _pbcV_encode32(uint32_t number, uint8_t buffer[10]); 12 | int _pbcV_encode(uint64_t number, uint8_t buffer[10]); 13 | int _pbcV_zigzag32(int32_t number, uint8_t buffer[10]); 14 | int _pbcV_zigzag(int64_t number, uint8_t buffer[10]); 15 | 16 | int _pbcV_decode(uint8_t buffer[10], struct longlong *result); 17 | void _pbcV_dezigzag64(struct longlong *r); 18 | void _pbcV_dezigzag32(struct longlong *r); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/http/url.lua: -------------------------------------------------------------------------------- 1 | local url = {} 2 | 3 | local function decode_func(c) 4 | return string.char(tonumber(c, 16)) 5 | end 6 | 7 | local function decode(str) 8 | local str = str:gsub('+', ' ') 9 | return str:gsub("%%(..)", decode_func) 10 | end 11 | 12 | function url.parse(u) 13 | local path,query = u:match "([^?]*)%??(.*)" 14 | if path then 15 | path = decode(path) 16 | end 17 | return path, query 18 | end 19 | 20 | function url.parse_query(q) 21 | local r = {} 22 | for k,v in q:gmatch "(.-)=([^&]*)&?" do 23 | r[decode(k)] = decode(v) 24 | end 25 | return r 26 | end 27 | 28 | return url 29 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/jemalloc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | objroot=$1 4 | 5 | cat <top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_ATOMIC_H 2 | #define SKYNET_ATOMIC_H 3 | 4 | #define ATOM_CAS(ptr, oval, nval) __sync_bool_compare_and_swap(ptr, oval, nval) 5 | #define ATOM_CAS_POINTER(ptr, oval, nval) __sync_bool_compare_and_swap(ptr, oval, nval) 6 | #define ATOM_INC(ptr) __sync_add_and_fetch(ptr, 1) 7 | #define ATOM_FINC(ptr) __sync_fetch_and_add(ptr, 1) 8 | #define ATOM_DEC(ptr) __sync_sub_and_fetch(ptr, 1) 9 | #define ATOM_FDEC(ptr) __sync_fetch_and_sub(ptr, 1) 10 | #define ATOM_ADD(ptr,n) __sync_add_and_fetch(ptr, n) 11 | #define ATOM_SUB(ptr,n) __sync_sub_and_fetch(ptr, n) 12 | #define ATOM_AND(ptr,n) __sync_and_and_fetch(ptr, n) 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/examples/userlog.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | require "skynet.manager" 3 | 4 | -- register protocol text before skynet.start would be better. 5 | skynet.register_protocol { 6 | name = "text", 7 | id = skynet.PTYPE_TEXT, 8 | unpack = skynet.tostring, 9 | dispatch = function(_, address, msg) 10 | print(string.format(":%08x(%.2f): %s", address, skynet.time(), msg)) 11 | end 12 | } 13 | 14 | skynet.register_protocol { 15 | name = "SYSTEM", 16 | id = skynet.PTYPE_SYSTEM, 17 | unpack = function(...) return ... end, 18 | dispatch = function() 19 | -- reopen signal 20 | print("SIGHUP") 21 | end 22 | } 23 | 24 | skynet.start(function() 25 | end) -------------------------------------------------------------------------------- /meiru/skynet/lualib/skynet/harbor.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local harbor = {} 4 | 5 | function harbor.globalname(name, handle) 6 | handle = handle or skynet.self() 7 | skynet.send(".cslave", "lua", "REGISTER", name, handle) 8 | end 9 | 10 | function harbor.queryname(name) 11 | return skynet.call(".cslave", "lua", "QUERYNAME", name) 12 | end 13 | 14 | function harbor.link(id) 15 | skynet.call(".cslave", "lua", "LINK", id) 16 | end 17 | 18 | function harbor.connect(id) 19 | skynet.call(".cslave", "lua", "CONNECT", id) 20 | end 21 | 22 | function harbor.linkmaster() 23 | skynet.call(".cslave", "lua", "LINKMASTER") 24 | end 25 | 26 | return harbor 27 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/socket_info.h: -------------------------------------------------------------------------------- 1 | #ifndef socket_info_h 2 | #define socket_info_h 3 | 4 | #define SOCKET_INFO_UNKNOWN 0 5 | #define SOCKET_INFO_LISTEN 1 6 | #define SOCKET_INFO_TCP 2 7 | #define SOCKET_INFO_UDP 3 8 | #define SOCKET_INFO_BIND 4 9 | 10 | #include 11 | 12 | struct socket_info { 13 | int id; 14 | int type; 15 | uint64_t opaque; 16 | uint64_t read; 17 | uint64_t write; 18 | uint64_t rtime; 19 | uint64_t wtime; 20 | int64_t wbuffer; 21 | char name[128]; 22 | struct socket_info *next; 23 | }; 24 | 25 | struct socket_info * socket_info_create(struct socket_info *last); 26 | void socket_info_release(struct socket_info *); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/public_unnamespace.h: -------------------------------------------------------------------------------- 1 | #undef je_aligned_alloc 2 | #undef je_calloc 3 | #undef je_dallocx 4 | #undef je_free 5 | #undef je_mallctl 6 | #undef je_mallctlbymib 7 | #undef je_mallctlnametomib 8 | #undef je_malloc 9 | #undef je_malloc_conf 10 | #undef je_malloc_message 11 | #undef je_malloc_stats_print 12 | #undef je_malloc_usable_size 13 | #undef je_mallocx 14 | #undef je_smallocx_b0b3e49a54ec29e32636f4577d9d5a896d67fd20 15 | #undef je_nallocx 16 | #undef je_posix_memalign 17 | #undef je_rallocx 18 | #undef je_realloc 19 | #undef je_sallocx 20 | #undef je_sdallocx 21 | #undef je_xallocx 22 | #undef je_memalign 23 | #undef je_valloc 24 | -------------------------------------------------------------------------------- /meiru/skynet/examples/main.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local sprotoloader = require "sprotoloader" 3 | 4 | local max_client = 64 5 | 6 | skynet.start(function() 7 | skynet.error("Server start") 8 | skynet.uniqueservice("protoloader") 9 | if not skynet.getenv "daemon" then 10 | local console = skynet.newservice("console") 11 | end 12 | skynet.newservice("debug_console",8000) 13 | skynet.newservice("simpledb") 14 | local watchdog = skynet.newservice("watchdog") 15 | skynet.call(watchdog, "lua", "start", { 16 | port = 8888, 17 | maxclient = max_client, 18 | nodelay = true, 19 | }) 20 | skynet.error("Watchdog listen on", 8888) 21 | skynet.exit() 22 | end) 23 | -------------------------------------------------------------------------------- /meiru/skynet/examples/injectlaunch.lua: -------------------------------------------------------------------------------- 1 | if not _P then 2 | print[[ 3 | This file is examples to show how to inject code into lua service. 4 | It is used to inject into launcher service to change the command.LAUNCH to command.LOGLAUNCH. 5 | telnet the debug_console service (nc 127.0.0.1 8000), and run: 6 | inject 3 examples/injectlaunch.lua -- 3 means launcher service 7 | ]] 8 | return 9 | end 10 | local command = _P.lua.command 11 | 12 | if command.RAWLAUNCH then 13 | command.LAUNCH, command.RAWLAUNCH = command.RAWLAUNCH 14 | print "restore command.LAUNCH" 15 | else 16 | command.RAWLAUNCH = command.LAUNCH 17 | command.LAUNCH = command.LOGLAUNCH 18 | print "replace command.LAUNCH" 19 | end 20 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/util/url.lua: -------------------------------------------------------------------------------- 1 | 2 | local url = {} 3 | 4 | local function decode_func(c) 5 | return string.char(tonumber(c, 16)) 6 | end 7 | 8 | local function decode(str) 9 | local str = str:gsub('+', ' ') 10 | return str:gsub("%%(..)", decode_func) 11 | end 12 | 13 | function url.parse_url(u) 14 | local path,query = u:match "([^?]*)%??(.*)" 15 | if path then 16 | path = decode(path) 17 | end 18 | return path, query 19 | end 20 | 21 | function url.parse_query(q) 22 | local r = {} 23 | for k,v in q:gmatch "(.-)=([^&]*)&?" do 24 | r[decode(k)] = decode(v) 25 | end 26 | return r 27 | end 28 | 29 | return url 30 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_handle.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_CONTEXT_HANDLE_H 2 | #define SKYNET_CONTEXT_HANDLE_H 3 | 4 | #include 5 | 6 | // reserve high 8 bits for remote id 7 | #define HANDLE_MASK 0xffffff 8 | #define HANDLE_REMOTE_SHIFT 24 9 | 10 | struct skynet_context; 11 | 12 | uint32_t skynet_handle_register(struct skynet_context *); 13 | int skynet_handle_retire(uint32_t handle); 14 | struct skynet_context * skynet_handle_grab(uint32_t handle); 15 | void skynet_handle_retireall(); 16 | 17 | uint32_t skynet_handle_findname(const char * name); 18 | const char * skynet_handle_namehandle(uint32_t handle, const char *name); 19 | 20 | void skynet_handle_init(int harbor); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comcors.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | local ComCors = class("ComCors", Com) 4 | 5 | --跨域限制 6 | ---------------------------------------------- 7 | --ComCors 8 | ---------------------------------------------- 9 | function ComCors:ctor() 10 | end 11 | 12 | function ComCors:match(req, res) 13 | local app = req.app 14 | if app.get('host') then 15 | local host = req.get('host') 16 | if not host then 17 | return false 18 | end 19 | local idx = host:find(":", 1, true) 20 | if idx then 21 | host = host:sub(1, idx-1) 22 | end 23 | if app.get('host') ~= host then 24 | assert(false) 25 | return false 26 | end 27 | end 28 | end 29 | 30 | return ComCors 31 | -------------------------------------------------------------------------------- /meiru/skynet/examples/proto.lua: -------------------------------------------------------------------------------- 1 | local sprotoparser = require "sprotoparser" 2 | 3 | local proto = {} 4 | 5 | proto.c2s = sprotoparser.parse [[ 6 | .package { 7 | type 0 : integer 8 | session 1 : integer 9 | } 10 | 11 | handshake 1 { 12 | response { 13 | msg 0 : string 14 | } 15 | } 16 | 17 | get 2 { 18 | request { 19 | what 0 : string 20 | } 21 | response { 22 | result 0 : string 23 | } 24 | } 25 | 26 | set 3 { 27 | request { 28 | what 0 : string 29 | value 1 : string 30 | } 31 | } 32 | 33 | quit 4 {} 34 | 35 | ]] 36 | 37 | proto.s2c = sprotoparser.parse [[ 38 | .package { 39 | type 0 : integer 40 | session 1 : integer 41 | } 42 | 43 | heartbeat 1 {} 44 | ]] 45 | 46 | return proto 47 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/Makefile.win: -------------------------------------------------------------------------------- 1 | # $Id: Makefile.win,v 1.11 2008/05/07 19:06:37 carregal Exp $ 2 | 3 | T= lfs 4 | 5 | include config.win 6 | 7 | SRCS= src\$T.c 8 | OBJS= src\$T.obj 9 | 10 | lib: src\lfs.dll 11 | 12 | .c.obj: 13 | $(CC) /c /Fo$@ $(CFLAGS) $< 14 | 15 | src\lfs.dll: $(OBJS) 16 | link /dll /def:src\$T.def /out:src\lfs.dll $(OBJS) "$(LUA_LIB)" 17 | IF EXIST src\lfs.dll.manifest mt -manifest src\lfs.dll.manifest -outputresource:src\lfs.dll;2 18 | 19 | install: src\lfs.dll 20 | IF NOT EXIST "$(LUA_LIBDIR)" mkdir "$(LUA_LIBDIR)" 21 | copy src\lfs.dll "$(LUA_LIBDIR)" 22 | 23 | clean: 24 | del src\lfs.dll $(OBJS) src\$T.lib src\$T.exp 25 | IF EXIST src\lfs.dll.manifest del src\lfs.dll.manifest -------------------------------------------------------------------------------- /meiru/skynet/lualib/sprotoloader.lua: -------------------------------------------------------------------------------- 1 | local parser = require "sprotoparser" 2 | local core = require "sproto.core" 3 | local sproto = require "sproto" 4 | 5 | local loader = {} 6 | 7 | function loader.register(filename, index) 8 | local f = assert(io.open(filename), "Can't open sproto file") 9 | local data = f:read "a" 10 | f:close() 11 | local sp = core.newproto(parser.parse(data)) 12 | core.saveproto(sp, index) 13 | end 14 | 15 | function loader.save(bin, index) 16 | local sp = core.newproto(bin) 17 | core.saveproto(sp, index) 18 | end 19 | 20 | function loader.load(index) 21 | local sp = core.loadproto(index) 22 | -- no __gc in metatable 23 | return sproto.sharenew(sp) 24 | end 25 | 26 | return loader 27 | 28 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/compath.lua: -------------------------------------------------------------------------------- 1 | 2 | local Com = include("com", ...) 3 | local url = include(".util.url", ...) 4 | 5 | ---------------------------------------------- 6 | --ComPath 7 | ---------------------------------------------- 8 | local ComPath = class("ComPath", Com) 9 | 10 | function ComPath:ctor() 11 | end 12 | 13 | function ComPath:match(req, res) 14 | req.path, req.query = url.parse_url(req.rawurl) 15 | local idx = req.path:find("/", 1, true) 16 | if idx ~= 1 then 17 | return false 18 | end 19 | if req.query then 20 | req.query = url.parse_query(req.query) 21 | else 22 | req.query = {} 23 | end 24 | req.path_params = req.path:split("/") 25 | end 26 | 27 | return ComPath 28 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_harbor.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_HARBOR_H 2 | #define SKYNET_HARBOR_H 3 | 4 | #include 5 | #include 6 | 7 | #define GLOBALNAME_LENGTH 16 8 | #define REMOTE_MAX 256 9 | 10 | struct remote_name { 11 | char name[GLOBALNAME_LENGTH]; 12 | uint32_t handle; 13 | }; 14 | 15 | struct remote_message { 16 | struct remote_name destination; 17 | const void * message; 18 | size_t sz; 19 | int type; 20 | }; 21 | 22 | void skynet_harbor_send(struct remote_message *rmsg, uint32_t source, int session); 23 | int skynet_harbor_message_isremote(uint32_t handle); 24 | void skynet_harbor_init(int harbor); 25 | void skynet_harbor_start(void * ctx); 26 | void skynet_harbor_exit(); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /meiru/skynet/test/testdatacenter.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local datacenter = require "skynet.datacenter" 3 | 4 | local function f1() 5 | print("====1==== wait hello") 6 | print("\t1>",datacenter.wait ("hello")) 7 | print("====1==== wait key.foobar") 8 | print("\t1>", pcall(datacenter.wait,"key")) -- will failed, because "key" is a branch 9 | print("\t1>",datacenter.wait ("key", "foobar")) 10 | end 11 | 12 | local function f2() 13 | skynet.sleep(10) 14 | print("====2==== set key.foobar") 15 | datacenter.set("key", "foobar", "bingo") 16 | end 17 | 18 | skynet.start(function() 19 | datacenter.set("hello", "world") 20 | print(datacenter.get "hello") 21 | skynet.fork(f1) 22 | skynet.fork(f2) 23 | end) 24 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/malloc_hook.h: -------------------------------------------------------------------------------- 1 | #ifndef SKYNET_MALLOC_HOOK_H 2 | #define SKYNET_MALLOC_HOOK_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern size_t malloc_used_memory(void); 9 | extern size_t malloc_memory_block(void); 10 | extern void memory_info_dump(void); 11 | extern size_t mallctl_int64(const char* name, size_t* newval); 12 | extern int mallctl_opt(const char* name, int* newval); 13 | extern bool mallctl_bool(const char* name, bool* newval); 14 | extern int mallctl_cmd(const char* name); 15 | extern void dump_c_mem(void); 16 | extern int dump_mem_lua(lua_State *L); 17 | extern size_t malloc_current_memory(void); 18 | 19 | #endif /* SKYNET_MALLOC_HOOK_H */ 20 | 21 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/binding/lua/test2.lua: -------------------------------------------------------------------------------- 1 | local protobuf = require "protobuf" 2 | 3 | addr = io.open("../../build/addressbook.pb","rb") 4 | buffer = addr:read "*a" 5 | addr:close() 6 | protobuf.register(buffer) 7 | 8 | local person = { 9 | name = "Alice", 10 | id = 123, 11 | phone = { 12 | { number = "123456789" , type = "MOBILE" }, 13 | { number = "87654321" , type = "HOME" }, 14 | } 15 | } 16 | 17 | local buffer = protobuf.encode("tutorial.Person", person) 18 | 19 | local t = protobuf.decode("tutorial.Person", buffer) 20 | 21 | for k,v in pairs(t) do 22 | if type(k) == "string" then 23 | print(k,v) 24 | end 25 | end 26 | 27 | print(t.phone[2].type) 28 | 29 | for k,v in pairs(t.phone[1]) do 30 | print(k,v) 31 | end 32 | 33 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/array.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_ARRAY_H 2 | #define PROTOBUF_C_ARRAY_H 3 | 4 | #include "varint.h" 5 | #include "pbc.h" 6 | #include "alloc.h" 7 | 8 | typedef union _pbc_var { 9 | struct longlong integer; 10 | double real; 11 | struct { 12 | const char * str; 13 | int len; 14 | } s; 15 | struct { 16 | int id; 17 | const char * name; 18 | } e; 19 | struct pbc_slice m; 20 | void * p[2]; 21 | } pbc_var[1]; 22 | 23 | void _pbcA_open(pbc_array); 24 | void _pbcA_open_heap(pbc_array, struct heap *h); 25 | void _pbcA_close(pbc_array); 26 | 27 | void _pbcA_push(pbc_array, pbc_var var); 28 | void _pbcA_index(pbc_array , int idx, pbc_var var); 29 | void * _pbcA_index_p(pbc_array _array, int idx); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/lib/emaild.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local _maild 4 | 5 | local thread_queue = {} 6 | 7 | skynet.fork(function() 8 | _maild = skynet.uniqueservice("meiru/lib/emaild") 9 | for _,thread in ipairs(thread_queue) do 10 | skynet.wakeup(thread) 11 | end 12 | thread_queue = nil 13 | end) 14 | 15 | local emaild = {} 16 | 17 | setmetatable(emaild, {__index = function(t,cmd) 18 | if not _maild then 19 | local thread = coroutine.running() 20 | table.insert(thread_queue, thread) 21 | skynet.wait(thread) 22 | end 23 | local f = function(...) 24 | return skynet.call(_maild, "lua", cmd, ...) 25 | end 26 | t[cmd] = f 27 | return f 28 | end}) 29 | 30 | return emaild -------------------------------------------------------------------------------- /meiru/skynet/examples/checkdeadloop.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local list = {} 4 | 5 | local function timeout_check(ti) 6 | if not next(list) then 7 | return 8 | end 9 | skynet.sleep(ti) -- sleep 10 sec 10 | for k,v in pairs(list) do 11 | skynet.error("timout",ti,k,v) 12 | end 13 | end 14 | 15 | skynet.start(function() 16 | skynet.error("ping all") 17 | local list_ret = skynet.call(".launcher", "lua", "LIST") 18 | for addr, desc in pairs(list_ret) do 19 | list[addr] = desc 20 | skynet.fork(function() 21 | skynet.call(addr,"debug","INFO") 22 | list[addr] = nil 23 | end) 24 | end 25 | skynet.sleep(0) 26 | timeout_check(100) 27 | timeout_check(400) 28 | timeout_check(500) 29 | skynet.exit() 30 | end) 31 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/example3.json: -------------------------------------------------------------------------------- 1 | {"widget": { 2 | "debug": "on", 3 | "window": { 4 | "title": "Sample Konfabulator Widget", 5 | "name": "main_window", 6 | "width": 500, 7 | "height": 500 8 | }, 9 | "image": { 10 | "src": "Images/Sun.png", 11 | "name": "sun1", 12 | "hOffset": 250, 13 | "vOffset": 250, 14 | "alignment": "center" 15 | }, 16 | "text": { 17 | "data": "Click Here", 18 | "size": 36, 19 | "style": "bold", 20 | "name": "text1", 21 | "hOffset": 250, 22 | "vOffset": 100, 23 | "alignment": "center", 24 | "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;" 25 | } 26 | }} 27 | -------------------------------------------------------------------------------- /meiru/skynet/skynet.dSYM/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleIdentifier 8 | com.apple.xcode.dsym.skynet 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | dSYM 13 | CFBundleSignature 14 | ???? 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleVersion 18 | 1 19 | 20 | 21 | -------------------------------------------------------------------------------- /meiru/skynet/test/testtimer.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local function timeout(t) 4 | print(t) 5 | end 6 | 7 | local function wakeup(co) 8 | for i=1,5 do 9 | skynet.sleep(50) 10 | skynet.wakeup(co) 11 | end 12 | end 13 | 14 | local function test() 15 | skynet.timeout(10, function() print("test timeout 10") end) 16 | for i=1,10 do 17 | print("test sleep",i,skynet.now()) 18 | skynet.sleep(1) 19 | end 20 | end 21 | 22 | skynet.start(function() 23 | test() 24 | 25 | skynet.fork(wakeup, coroutine.running()) 26 | skynet.timeout(300, function() timeout "Hello World" end) 27 | for i = 1, 10 do 28 | print(i, skynet.now()) 29 | print(skynet.sleep(100)) 30 | end 31 | skynet.exit() 32 | print("Test timer exit") 33 | 34 | end) 35 | -------------------------------------------------------------------------------- /meiru/skynet/test/testudp.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local socket = require "skynet.socket" 3 | 4 | local function server() 5 | local host 6 | host = socket.udp(function(str, from) 7 | print("server recv", str, socket.udp_address(from)) 8 | socket.sendto(host, from, "OK " .. str) 9 | end , "127.0.0.1", 8765) -- bind an address 10 | end 11 | 12 | local function client() 13 | local c = socket.udp(function(str, from) 14 | print("client recv", str, socket.udp_address(from)) 15 | end) 16 | socket.udp_connect(c, "127.0.0.1", 8765) 17 | for i=1,20 do 18 | socket.write(c, "hello " .. i) -- write to the address by udp_connect binding 19 | end 20 | end 21 | 22 | skynet.start(function() 23 | skynet.fork(server) 24 | skynet.fork(client) 25 | end) 26 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/lib/uuid.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | local function num_to_num36(num) 4 | local num36 = "" 5 | while num > 0 do 6 | local remainder = num%36 7 | if remainder>9 then 8 | num36 = string.char(remainder-10+97) .. num36 9 | else 10 | num36 = string.char(remainder+48) .. num36 11 | end 12 | num = math.floor(num/36) 13 | end 14 | return num36 15 | end 16 | 17 | local __suid = 1 18 | math.randomseed(os.time()) 19 | local function generate_uuid() 20 | local id = num_to_num36(os.time()) 21 | .. num_to_num36(math.random(100000000, 1000000000-1)) 22 | .. num_to_num36(__suid) 23 | __suid = __suid+1 24 | return id 25 | end 26 | 27 | return generate_uuid 28 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/lib/systemd.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local _systemd 4 | 5 | local thread_queue = {} 6 | 7 | skynet.fork(function() 8 | _systemd = skynet.uniqueservice("meiru/lib/systemd") 9 | for _,thread in ipairs(thread_queue) do 10 | skynet.wakeup(thread) 11 | end 12 | thread_queue = nil 13 | end) 14 | 15 | 16 | local systemd = {} 17 | 18 | setmetatable(systemd, {__index = function(t, cmd) 19 | if not _systemd then 20 | local thread = coroutine.running() 21 | table.insert(thread_queue, thread) 22 | skynet.wait(thread) 23 | end 24 | local f = function(...) 25 | return skynet.call(_systemd, "lua", cmd, ...) 26 | end 27 | t[cmd] = f 28 | return f 29 | end}) 30 | 31 | 32 | return systemd -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comresponse.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | ---------------------------------------------- 4 | --ComResponse 5 | ---------------------------------------------- 6 | local ComResponse = class("ComResponse", Com) 7 | 8 | function ComResponse:ctor() 9 | end 10 | 11 | function ComResponse:match(req, res) 12 | if res.req_ret == true then 13 | res.app.response(res, res.get_statuscode(), res.get_body(), res.get_header()) 14 | log("dispatch success:", req.rawurl) 15 | return true 16 | elseif res.req_ret == false then 17 | log("dispatch failed:", req.rawreq) 18 | else 19 | log("dispatch nothing:", req.rawreq) 20 | assert(not res.is_end) 21 | end 22 | res.app.response(res, 404, "HelloWorld404") 23 | return true 24 | end 25 | 26 | return ComResponse 27 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/public_symbols.txt: -------------------------------------------------------------------------------- 1 | aligned_alloc:je_aligned_alloc 2 | calloc:je_calloc 3 | dallocx:je_dallocx 4 | free:je_free 5 | mallctl:je_mallctl 6 | mallctlbymib:je_mallctlbymib 7 | mallctlnametomib:je_mallctlnametomib 8 | malloc:je_malloc 9 | malloc_conf:je_malloc_conf 10 | malloc_message:je_malloc_message 11 | malloc_stats_print:je_malloc_stats_print 12 | malloc_usable_size:je_malloc_usable_size 13 | mallocx:je_mallocx 14 | smallocx_b0b3e49a54ec29e32636f4577d9d5a896d67fd20:je_smallocx_b0b3e49a54ec29e32636f4577d9d5a896d67fd20 15 | nallocx:je_nallocx 16 | posix_memalign:je_posix_memalign 17 | rallocx:je_rallocx 18 | realloc:je_realloc 19 | sallocx:je_sallocx 20 | sdallocx:je_sdallocx 21 | xallocx:je_xallocx 22 | memalign:je_memalign 23 | valloc:je_valloc 24 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/genutf8.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # Create test comparison data using a different UTF-8 implementation. 4 | 5 | # The generated utf8.dat file must have the following MD5 sum: 6 | # cff03b039d850f370a7362f3313e5268 7 | 8 | use strict; 9 | no warnings 'nonchar'; 10 | 11 | # 0xD800 - 0xDFFF are used to encode supplementary codepoints 12 | # 0x10000 - 0x10FFFF are supplementary codepoints 13 | my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF); 14 | 15 | my $utf8 = pack("U*", @codepoints); 16 | defined($utf8) or die "Unable create UTF-8 string\n"; 17 | 18 | open(FH, ">:utf8", "utf8.dat") 19 | or die "Unable to open utf8.dat: $!\n"; 20 | print FH $utf8 21 | or die "Unable to write utf8.dat\n"; 22 | close(FH); 23 | 24 | # vi:ai et sw=4 ts=4: 25 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/config: -------------------------------------------------------------------------------- 1 | # Installation directories 2 | 3 | # Default installation prefix 4 | PREFIX=/usr/local 5 | 6 | # System's libraries directory (where binary libraries are installed) 7 | LUA_LIBDIR= $(PREFIX)/lib/lua/5.1 8 | 9 | # Lua includes directory 10 | LUA_INC += -I$(PREFIX)/include 11 | LUA_INC += -I/usr/include/lua5.1 12 | 13 | # OS dependent 14 | LIB_OPTION= -shared #for Linux 15 | #LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X 16 | 17 | LIBNAME= $T.so.$V 18 | 19 | # Compilation directives 20 | WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic 21 | INCS= $(LUA_INC) 22 | CFLAGS= $(WARN) $(INCS) 23 | CC= gcc 24 | 25 | # $Id: config,v 1.21 2007/10/27 22:42:32 carregal Exp $ 26 | -------------------------------------------------------------------------------- /meiru/skynet/examples/cluster1.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local cluster = require "skynet.cluster" 3 | local snax = require "skynet.snax" 4 | 5 | skynet.start(function() 6 | cluster.reload { 7 | db = "127.0.0.1:2528", 8 | db2 = "127.0.0.1:2529", 9 | } 10 | 11 | local sdb = skynet.newservice("simpledb") 12 | -- register name "sdb" for simpledb, you can use cluster.query() later. 13 | -- See cluster2.lua 14 | cluster.register("sdb", sdb) 15 | 16 | print(skynet.call(sdb, "lua", "SET", "a", "foobar")) 17 | print(skynet.call(sdb, "lua", "SET", "b", "foobar2")) 18 | print(skynet.call(sdb, "lua", "GET", "a")) 19 | print(skynet.call(sdb, "lua", "GET", "b")) 20 | cluster.open "db" 21 | cluster.open "db2" 22 | -- unique snax service 23 | snax.uniqueservice "pingserver" 24 | end) 25 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comcookie.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | local Cookie = include(".util.cookie", ...) 3 | 4 | ---------------------------------------------- 5 | --ComCookie 6 | ---------------------------------------------- 7 | local ComCookie = class("ComCookie", Com) 8 | 9 | function ComCookie:ctor() 10 | end 11 | 12 | function ComCookie:match(req, res) 13 | if not req.cookies then 14 | if not req.get('cookie') then 15 | req.cookies = {} 16 | req.signcookies = {} 17 | else 18 | local session_secret = req.app.get("session_secret") or "meiru" 19 | local cookies, signcookies = Cookie.cookie_decode(req.get('cookie'), session_secret) 20 | req.cookies = cookies or {} 21 | req.signcookies = signcookies or {} 22 | end 23 | end 24 | end 25 | 26 | return ComCookie 27 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/vc6/luafilesystem.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "luafilesystem_dll"=.\luafilesystem_dll.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | begin source code control 11 | luafilesystem 12 | .. 13 | end source code control 14 | }}} 15 | 16 | Package=<4> 17 | {{{ 18 | }}} 19 | 20 | ############################################################################### 21 | 22 | Global: 23 | 24 | Package=<5> 25 | {{{ 26 | }}} 27 | 28 | Package=<3> 29 | {{{ 30 | }}} 31 | 32 | ############################################################################### 33 | 34 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-md5/compat-5.2.c: -------------------------------------------------------------------------------- 1 | #include "lua.h" 2 | #include "lauxlib.h" 3 | #include "compat-5.2.h" 4 | 5 | #if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501 6 | /* 7 | ** Adapted from Lua 5.2.0 8 | */ 9 | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { 10 | luaL_checkstack(L, nup+1, "too many upvalues"); 11 | for (; l->name != NULL; l++) { /* fill the table with given functions */ 12 | int i; 13 | lua_pushstring(L, l->name); 14 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ 15 | lua_pushvalue(L, -(nup + 1)); 16 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ 17 | lua_settable(L, -(nup + 3)); /* table must be below the upvalues, the name and the closure */ 18 | } 19 | lua_pop(L, nup); /* remove upvalues */ 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_ALLOC_H 2 | #define PROTOBUF_C_ALLOC_H 3 | 4 | #include 5 | #include 6 | 7 | void * _pbcM_malloc(size_t sz); 8 | void _pbcM_free(void *p); 9 | void * _pbcM_realloc(void *p, size_t sz); 10 | void _pbcM_memory(); 11 | 12 | struct heap; 13 | 14 | struct heap * _pbcH_new(int pagesize); 15 | void _pbcH_delete(struct heap *); 16 | void* _pbcH_alloc(struct heap *, int size); 17 | 18 | #define HMALLOC(size) ((h) ? _pbcH_alloc(h, size) : _pbcM_malloc(size)) 19 | 20 | #define malloc _pbcM_malloc 21 | #define free _pbcM_free 22 | #define realloc _pbcM_realloc 23 | #define memory _pbcM_memory 24 | 25 | #ifdef _WIN32 26 | 27 | #include 28 | 29 | #endif 30 | 31 | #ifdef _MSC_VER 32 | 33 | #define alloca _alloca 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /meiru/skynet/test/testmulticast2.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local dc = require "skynet.datacenter" 3 | local mc = require "skynet.multicast" 4 | 5 | skynet.start(function() 6 | print("remote start") 7 | local console = skynet.newservice("console") 8 | local channel = dc.get "MCCHANNEL" 9 | if channel then 10 | print("remote channel", channel) 11 | else 12 | print("create local channel") 13 | end 14 | for i=1,10 do 15 | local sub = skynet.newservice("testmulticast", "sub") 16 | skynet.call(sub, "lua", "init", channel) 17 | end 18 | local c = mc.new { 19 | channel = channel , 20 | dispatch = function(...) print("======>", ...) end, 21 | } 22 | c:subscribe() 23 | c:publish("Remote message") 24 | c:unsubscribe() 25 | c:publish("Remote message2") 26 | c:delete() 27 | skynet.exit() 28 | end) 29 | -------------------------------------------------------------------------------- /meiru/skynet/service/console.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local snax = require "skynet.snax" 3 | local socket = require "skynet.socket" 4 | 5 | local function split_cmdline(cmdline) 6 | local split = {} 7 | for i in string.gmatch(cmdline, "%S+") do 8 | table.insert(split,i) 9 | end 10 | return split 11 | end 12 | 13 | local function console_main_loop() 14 | local stdin = socket.stdin() 15 | while true do 16 | local cmdline = socket.readline(stdin, "\n") 17 | local split = split_cmdline(cmdline) 18 | local command = split[1] 19 | if command == "snax" then 20 | pcall(snax.newservice, select(2, table.unpack(split))) 21 | elseif cmdline ~= "" then 22 | pcall(skynet.newservice, cmdline) 23 | end 24 | end 25 | end 26 | 27 | skynet.start(function() 28 | skynet.fork(console_main_loop) 29 | end) 30 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/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 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/combody.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | 3 | 4 | ---------------------------------------------- 5 | --ComBody 6 | ---------------------------------------------- 7 | local ComBody = class("ComBody", Com) 8 | 9 | function ComBody:ctor() 10 | end 11 | 12 | function ComBody:match(req, res) 13 | local content_type = req.header['content-type'] 14 | if type(content_type) ~= 'string' then 15 | return 16 | end 17 | local ret = content_type:find('application/x-www-form-urlencoded', 1, true) 18 | if ret and type(req.rawbody) == 'string' then 19 | local tmp = req.rawbody 20 | local items = tmp:split("&") 21 | local body = {} 22 | for _,item in ipairs(items) do 23 | tmp = item:split("=") 24 | body[tmp[1]] = tmp[2] and tmp[2]:urldecode() or "" 25 | end 26 | req.body = body 27 | end 28 | end 29 | 30 | return ComBody 31 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/luafilesystem-scm-1.rockspec: -------------------------------------------------------------------------------- 1 | package = "luafilesystem" 2 | version = "scm-1" 3 | source = { 4 | url = "git://github.com/keplerproject/luafilesystem" 5 | } 6 | description = { 7 | summary = "File System Library for the Lua Programming Language", 8 | detailed = [[ 9 | LuaFileSystem is a Lua library developed to complement the set of 10 | functions related to file systems offered by the standard Lua 11 | distribution. LuaFileSystem offers a portable way to access the 12 | underlying directory structure and file attributes. 13 | ]], 14 | license = "MIT/X11" 15 | } 16 | dependencies = { 17 | "lua >= 5.1" 18 | } 19 | build = { 20 | type = "builtin", 21 | modules = { 22 | lfs = "src/lfs.c" 23 | }, 24 | copy_directories = { 25 | "doc", 26 | "tests" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /meiru/skynet/lualib-src/sproto/msvcint.h: -------------------------------------------------------------------------------- 1 | #ifndef msvc_int_h 2 | #define msvc_int_h 3 | 4 | #ifdef _MSC_VER 5 | # define inline __inline 6 | # ifndef _MSC_STDINT_H_ 7 | # if (_MSC_VER < 1300) 8 | typedef signed char int8_t; 9 | typedef signed short int16_t; 10 | typedef signed int int32_t; 11 | typedef unsigned char uint8_t; 12 | typedef unsigned short uint16_t; 13 | typedef unsigned int uint32_t; 14 | # else 15 | typedef signed __int8 int8_t; 16 | typedef signed __int16 int16_t; 17 | typedef signed __int32 int32_t; 18 | typedef unsigned __int8 uint8_t; 19 | typedef unsigned __int16 uint16_t; 20 | typedef unsigned __int32 uint32_t; 21 | # endif 22 | typedef signed __int64 int64_t; 23 | typedef unsigned __int64 uint64_t; 24 | # endif 25 | 26 | #else 27 | 28 | #include 29 | 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/src/lfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaFileSystem 3 | ** Copyright Kepler Project 2003 - 2017 (http://keplerproject.github.io/luafilesystem) 4 | */ 5 | 6 | /* Define 'chdir' for systems that do not implement it */ 7 | #ifdef NO_CHDIR 8 | #define chdir(p) (-1) 9 | #define chdir_error "Function 'chdir' not provided by system" 10 | #else 11 | #define chdir_error strerror(errno) 12 | #endif 13 | 14 | #ifdef _WIN32 15 | #define chdir(p) (_chdir(p)) 16 | #define getcwd(d, s) (_getcwd(d, s)) 17 | #define rmdir(p) (_rmdir(p)) 18 | #define LFS_EXPORT __declspec (dllexport) 19 | #ifndef fileno 20 | #define fileno(f) (_fileno(f)) 21 | #endif 22 | #else 23 | #define LFS_EXPORT 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | LFS_EXPORT int luaopen_lfs (lua_State *L); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/socket_poll.h: -------------------------------------------------------------------------------- 1 | #ifndef socket_poll_h 2 | #define socket_poll_h 3 | 4 | #include 5 | 6 | typedef int poll_fd; 7 | 8 | struct event { 9 | void * s; 10 | bool read; 11 | bool write; 12 | bool error; 13 | bool eof; 14 | }; 15 | 16 | static bool sp_invalid(poll_fd fd); 17 | static poll_fd sp_create(); 18 | static void sp_release(poll_fd fd); 19 | static int sp_add(poll_fd fd, int sock, void *ud); 20 | static void sp_del(poll_fd fd, int sock); 21 | static void sp_write(poll_fd, int sock, void *ud, bool enable); 22 | static int sp_wait(poll_fd, struct event *e, int max); 23 | static void sp_nonblocking(int sock); 24 | 25 | #ifdef __linux__ 26 | #include "socket_epoll.h" 27 | #endif 28 | 29 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__) 30 | #include "socket_kqueue.h" 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /meiru/skynet/test/testmemlimit.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local names = { 4 | "cluster", 5 | "skynet.db.dns", 6 | "skynet.db.mongo", 7 | "skynet.db.mysql", 8 | "skynet.db.redis", 9 | "sharedata", 10 | "skynet.socket", 11 | "sproto" 12 | } 13 | 14 | -- set sandbox memory limit to 1M, must set here (at start, out of skynet.start) 15 | skynet.memlimit(1 * 1024 * 1024) 16 | 17 | skynet.start(function() 18 | local a = {} 19 | local limit 20 | local ok, err = pcall(function() 21 | for i=1, 12355 do 22 | limit = i 23 | table.insert(a, {}) 24 | end 25 | end) 26 | local libs = {} 27 | for k,v in ipairs(names) do 28 | local ok, m = pcall(require, v) 29 | if ok then 30 | libs[v] = m 31 | end 32 | end 33 | skynet.error(limit, err) 34 | skynet.exit() 35 | end) 36 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/pages.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_pages_huge) { 4 | size_t alloc_size; 5 | bool commit; 6 | void *pages, *hugepage; 7 | 8 | alloc_size = HUGEPAGE * 2 - PAGE; 9 | commit = true; 10 | pages = pages_map(NULL, alloc_size, PAGE, &commit); 11 | assert_ptr_not_null(pages, "Unexpected pages_map() error"); 12 | 13 | if (init_system_thp_mode == thp_mode_default) { 14 | hugepage = (void *)(ALIGNMENT_CEILING((uintptr_t)pages, HUGEPAGE)); 15 | assert_b_ne(pages_huge(hugepage, HUGEPAGE), have_madvise_huge, 16 | "Unexpected pages_huge() result"); 17 | assert_false(pages_nohuge(hugepage, HUGEPAGE), 18 | "Unexpected pages_nohuge() result"); 19 | } 20 | 21 | pages_unmap(pages, alloc_size); 22 | } 23 | TEST_END 24 | 25 | int 26 | main(void) { 27 | return test( 28 | test_pages_huge); 29 | } 30 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/extent_dss.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_EXTENT_DSS_H 2 | #define JEMALLOC_INTERNAL_EXTENT_DSS_H 3 | 4 | typedef enum { 5 | dss_prec_disabled = 0, 6 | dss_prec_primary = 1, 7 | dss_prec_secondary = 2, 8 | 9 | dss_prec_limit = 3 10 | } dss_prec_t; 11 | #define DSS_PREC_DEFAULT dss_prec_secondary 12 | #define DSS_DEFAULT "secondary" 13 | 14 | extern const char *dss_prec_names[]; 15 | 16 | extern const char *opt_dss; 17 | 18 | dss_prec_t extent_dss_prec_get(void); 19 | bool extent_dss_prec_set(dss_prec_t dss_prec); 20 | void *extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, 21 | size_t size, size_t alignment, bool *zero, bool *commit); 22 | bool extent_in_dss(void *addr); 23 | bool extent_dss_mergeable(void *addr_a, void *addr_b); 24 | void extent_dss_boot(void); 25 | 26 | #endif /* JEMALLOC_INTERNAL_EXTENT_DSS_H */ 27 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/control: -------------------------------------------------------------------------------- 1 | Source: lua-iconv 2 | Section: interpreters 3 | Priority: optional 4 | Maintainer: Jon Bernard 5 | Build-Depends: debhelper (>= 7), liblua5.2-dev, lua5.2, pkg-config 6 | Standards-Version: 3.8.2 7 | Vcs-Git: https://github.com/ittner/lua-iconv.git 8 | Vcs-Browser: https://github.com/ittner/lua-iconv.git 9 | Homepage: http://ittner.github.com/lua-iconv/ 10 | 11 | Package: liblua5.2-iconv0 12 | Architecture: any 13 | Depends: ${shlibs:Depends}, ${misc:Depends} 14 | Recommends: lua5.2 15 | Conflicts: lua-iconv 16 | Provides: lua-iconv 17 | Replaces: lua-iconv 18 | Description: iconv bindings for the Lua programming language 19 | This package provides POSIX 'iconv' bindings for the Lua programming language. 20 | It converts a sequence of characters from one codeset into a sequence of 21 | corresponding characters in another codeset. 22 | -------------------------------------------------------------------------------- /meiru/skynet/test/teststm.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local stm = require "skynet.stm" 3 | 4 | local mode = ... 5 | 6 | if mode == "slave" then 7 | 8 | skynet.start(function() 9 | skynet.dispatch("lua", function (_,_, obj) 10 | local obj = stm.newcopy(obj) 11 | print("read:", obj(skynet.unpack)) 12 | skynet.ret() 13 | skynet.error("sleep and read") 14 | for i=1,10 do 15 | skynet.sleep(10) 16 | print("read:", obj(skynet.unpack)) 17 | end 18 | skynet.exit() 19 | end) 20 | end) 21 | 22 | else 23 | 24 | skynet.start(function() 25 | local slave = skynet.newservice(SERVICE_NAME, "slave") 26 | local obj = stm.new(skynet.pack(1,2,3,4,5)) 27 | local copy = stm.copy(obj) 28 | skynet.call(slave, "lua", copy) 29 | for i=1,5 do 30 | skynet.sleep(20) 31 | print("write", i) 32 | obj(skynet.pack("hello world", i)) 33 | end 34 | skynet.exit() 35 | end) 36 | end 37 | -------------------------------------------------------------------------------- /meiru/skynet/test/testping.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local snax = require "skynet.snax" 3 | 4 | skynet.start(function() 5 | skynet.trace() 6 | local ps = snax.newservice ("pingserver", "hello world") 7 | print(ps.req.ping("foobar")) 8 | print(ps.post.hello()) 9 | print(pcall(ps.req.error)) 10 | print("Hotfix (i) :", snax.hotfix(ps, [[ 11 | 12 | local i 13 | local hello 14 | 15 | function accept.hello() 16 | i = i + 1 17 | print ("fix", i, hello) 18 | end 19 | 20 | function hotfix(...) 21 | local temp = i 22 | i = 100 23 | return temp 24 | end 25 | 26 | ]])) 27 | print(ps.post.hello()) 28 | 29 | local info = skynet.call(ps.handle, "debug", "INFO") 30 | 31 | for name,v in pairs(info) do 32 | print(string.format("%s\tcount:%d time:%f", name, v.count, v.time)) 33 | end 34 | 35 | print(ps.post.exit("exit")) -- == snax.kill(ps, "exit") 36 | skynet.exit() 37 | end) 38 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef skynet_malloc_h 2 | #define skynet_malloc_h 3 | 4 | #include 5 | 6 | #define skynet_malloc malloc 7 | #define skynet_calloc calloc 8 | #define skynet_realloc realloc 9 | #define skynet_free free 10 | #define skynet_memalign memalign 11 | #define skynet_aligned_alloc aligned_alloc 12 | #define skynet_posix_memalign posix_memalign 13 | 14 | void * skynet_malloc(size_t sz); 15 | void * skynet_calloc(size_t nmemb,size_t size); 16 | void * skynet_realloc(void *ptr, size_t size); 17 | void skynet_free(void *ptr); 18 | char * skynet_strdup(const char *str); 19 | void * skynet_lalloc(void *ptr, size_t osize, size_t nsize); // use for lua 20 | void * skynet_memalign(size_t alignment, size_t size); 21 | void * skynet_aligned_alloc(size_t alignment, size_t size); 22 | int skynet_posix_memalign(void **memptr, size_t alignment, size_t size); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lpeg/lpprint.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lpprint.h,v 1.2 2015/06/12 18:18:08 roberto Exp $ 3 | */ 4 | 5 | 6 | #if !defined(lpprint_h) 7 | #define lpprint_h 8 | 9 | 10 | #include "lptree.h" 11 | #include "lpvm.h" 12 | 13 | 14 | #if defined(LPEG_DEBUG) 15 | 16 | void printpatt (Instruction *p, int n); 17 | void printtree (TTree *tree, int ident); 18 | void printktable (lua_State *L, int idx); 19 | void printcharset (const byte *st); 20 | void printcaplist (Capture *cap, Capture *limit); 21 | void printinst (const Instruction *op, const Instruction *p); 22 | 23 | #else 24 | 25 | #define printktable(L,idx) \ 26 | luaL_error(L, "function only implemented in debug mode") 27 | #define printtree(tree,i) \ 28 | luaL_error(L, "function only implemented in debug mode") 29 | #define printpatt(p,n) \ 30 | luaL_error(L, "function only implemented in debug mode") 31 | 32 | #endif 33 | 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /meiru/skynet/service/debug_agent.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local debugchannel = require "skynet.debugchannel" 3 | 4 | local CMD = {} 5 | 6 | local channel 7 | 8 | function CMD.start(address, fd) 9 | assert(channel == nil, "start more than once") 10 | skynet.error(string.format("Attach to :%08x", address)) 11 | local handle 12 | channel, handle = debugchannel.create() 13 | local ok, err = pcall(skynet.call, address, "debug", "REMOTEDEBUG", fd, handle) 14 | if not ok then 15 | skynet.ret(skynet.pack(false, "Debugger attach failed")) 16 | else 17 | -- todo hook 18 | skynet.ret(skynet.pack(true)) 19 | end 20 | skynet.exit() 21 | end 22 | 23 | function CMD.cmd(cmdline) 24 | channel:write(cmdline) 25 | end 26 | 27 | function CMD.ping() 28 | skynet.ret() 29 | end 30 | 31 | skynet.start(function() 32 | skynet.dispatch("lua", function(_,_,cmd,...) 33 | local f = CMD[cmd] 34 | f(...) 35 | end) 36 | end) 37 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/src/thd.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | #ifdef _WIN32 4 | void 5 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 6 | LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc; 7 | *thd = CreateThread(NULL, 0, routine, arg, 0, NULL); 8 | if (*thd == NULL) { 9 | test_fail("Error in CreateThread()\n"); 10 | } 11 | } 12 | 13 | void 14 | thd_join(thd_t thd, void **ret) { 15 | if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) { 16 | DWORD exit_code; 17 | GetExitCodeThread(thd, (LPDWORD) &exit_code); 18 | *ret = (void *)(uintptr_t)exit_code; 19 | } 20 | } 21 | 22 | #else 23 | void 24 | thd_create(thd_t *thd, void *(*proc)(void *), void *arg) { 25 | if (pthread_create(thd, NULL, proc, arg) != 0) { 26 | test_fail("Error in pthread_create()\n"); 27 | } 28 | } 29 | 30 | void 31 | thd_join(thd_t thd, void **ret) { 32 | pthread_join(thd, ret); 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /meiru/skynet/test/testdeadcall.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local mode = ... 4 | 5 | if mode == "test" then 6 | 7 | skynet.start(function() 8 | skynet.dispatch("lua", function (...) 9 | print("====>", ...) 10 | skynet.exit() 11 | end) 12 | end) 13 | 14 | elseif mode == "dead" then 15 | 16 | skynet.start(function() 17 | skynet.dispatch("lua", function (...) 18 | skynet.sleep(100) 19 | print("return", skynet.ret "") 20 | end) 21 | end) 22 | 23 | else 24 | 25 | skynet.start(function() 26 | local test = skynet.newservice(SERVICE_NAME, "test") -- launch self in test mode 27 | 28 | print(pcall(function() 29 | skynet.call(test,"lua", "dead call") 30 | end)) 31 | 32 | local dead = skynet.newservice(SERVICE_NAME, "dead") -- launch self in dead mode 33 | 34 | skynet.timeout(0, skynet.exit) -- exit after a while, so the call never return 35 | skynet.call(dead, "lua", "would not return") 36 | end) 37 | end 38 | -------------------------------------------------------------------------------- /meiru/service/meiru/ip2regiond.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local ip2region = require "ip2region" 3 | 4 | local command = {} 5 | 6 | function command.start(db_file) 7 | local result = ip2region.init(db_file) 8 | if not result then 9 | error("载入 ip 地址库错误!", db_file) 10 | return false 11 | end 12 | end 13 | 14 | function command.ip2region(ip) 15 | return ip2region.find(ip) 16 | end 17 | 18 | function command.ips2region(ips) 19 | local ret = {} 20 | for _,ip in ipairs(ips) do 21 | ret[ip] = ip2region.find(ip) 22 | end 23 | return ret 24 | end 25 | 26 | skynet.start(function() 27 | skynet.dispatch("lua", function(_,_,cmd,...) 28 | local f = command[cmd] 29 | if f then 30 | skynet.ret(skynet.pack(f(...))) 31 | else 32 | assert(false, "error no support cmd"..cmd) 33 | end 34 | end) 35 | end) 36 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/README.adoc: -------------------------------------------------------------------------------- 1 | = Lua CJSON = 2 | Mark Pulford 3 | 4 | The Lua CJSON module provides JSON support for Lua. 5 | 6 | *Features*:: 7 | - Fast, standards compliant encoding/parsing routines 8 | - Full support for JSON with UTF-8, including decoding surrogate pairs 9 | - Optional run-time support for common exceptions to the JSON 10 | specification (infinity, NaN,..) 11 | - No dependencies on other libraries 12 | 13 | *Caveats*:: 14 | - UTF-16 and UTF-32 are not supported 15 | 16 | Lua CJSON is covered by the MIT license. Review the file +LICENSE+ for 17 | details. 18 | 19 | Please read +manual.adoc+ for installation instructions and the API 20 | manual. 21 | 22 | The current stable version of this software is available from the 23 | http://www.kyne.com.au/%7Emark/software/lua-cjson.php[Lua CJSON website]. 24 | 25 | Feel free to email me if you have any patches, suggestions, or comments. 26 | 27 | // vi:ft=asciidoc tw=72: 28 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.0.1.{build}-test 2 | 3 | # Use default image unless needed 4 | #os: 5 | #- Windows Server 2012 R2 6 | 7 | shallow_clone: true 8 | 9 | environment: 10 | matrix: 11 | - LUA: "lua 5.1" 12 | - LUA: "lua 5.2 --compat none" 13 | - LUA: "lua 5.3 --compat none" 14 | - LUA: "luajit 2.0" 15 | - LUA: "luajit 2.1" 16 | 17 | # Abuse this section so we can have a matrix with different Compiler versions 18 | configuration: 19 | - mingw 20 | - vs_32 21 | - vs_64 22 | 23 | install: 24 | - set PATH=%CD%\env\bin;C:\Python27\Scripts;C:\MinGW\bin;%PATH% 25 | - pip install hererocks 26 | - hererocks env --%LUA% --target %configuration% --luarocks latest 27 | 28 | before_build: 29 | # @todo 30 | - echo "Installing external deps" 31 | 32 | build_script: 33 | - luarocks make 34 | 35 | before_test: 36 | 37 | test_script: 38 | - echo "Testing..." 39 | - lua tests/test.lua 40 | 41 | after_test: 42 | # @todo 43 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/pbc.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pbc", "pbc.vcxproj", "{82356F33-956B-4931-9977-BD7994B1C761}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {82356F33-956B-4931-9977-BD7994B1C761}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {82356F33-956B-4931-9977-BD7994B1C761}.Debug|Win32.Build.0 = Debug|Win32 14 | {82356F33-956B-4931-9977-BD7994B1C761}.Release|Win32.ActiveCfg = Release|Win32 15 | {82356F33-956B-4931-9977-BD7994B1C761}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /meiru/skynet/test/testoverload.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local mode = ... 4 | 5 | if mode == "slave" then 6 | 7 | local CMD = {} 8 | 9 | function CMD.sum(n) 10 | skynet.error("for loop begin") 11 | local s = 0 12 | for i = 1, n do 13 | s = s + i 14 | end 15 | skynet.error("for loop end") 16 | end 17 | 18 | function CMD.blackhole() 19 | end 20 | 21 | skynet.start(function() 22 | skynet.dispatch("lua", function(_,_, cmd, ...) 23 | local f = CMD[cmd] 24 | f(...) 25 | end) 26 | end) 27 | 28 | else 29 | 30 | skynet.start(function() 31 | local slave = skynet.newservice(SERVICE_NAME, "slave") 32 | for step = 1, 20 do 33 | skynet.error("overload test ".. step) 34 | for i = 1, 512 * step do 35 | skynet.send(slave, "lua", "blackhole") 36 | end 37 | skynet.sleep(step) 38 | end 39 | local n = 1000000000 40 | skynet.error(string.format("endless test n=%d", n)) 41 | skynet.send(slave, "lua", "sum", n) 42 | end) 43 | 44 | end 45 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/test_hooks.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static bool hook_called = false; 4 | 5 | static void 6 | hook() { 7 | hook_called = true; 8 | } 9 | 10 | static int 11 | func_to_hook(int arg1, int arg2) { 12 | return arg1 + arg2; 13 | } 14 | 15 | #define func_to_hook JEMALLOC_HOOK(func_to_hook, test_hooks_libc_hook) 16 | 17 | TEST_BEGIN(unhooked_call) { 18 | test_hooks_libc_hook = NULL; 19 | hook_called = false; 20 | assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 21 | assert_false(hook_called, "Nulling out hook didn't take."); 22 | } 23 | TEST_END 24 | 25 | TEST_BEGIN(hooked_call) { 26 | test_hooks_libc_hook = &hook; 27 | hook_called = false; 28 | assert_d_eq(3, func_to_hook(1, 2), "Hooking changed return value."); 29 | assert_true(hook_called, "Hook should have executed."); 30 | } 31 | TEST_END 32 | 33 | int 34 | main(void) { 35 | return test( 36 | unhooked_call, 37 | hooked_call); 38 | } 39 | -------------------------------------------------------------------------------- /meiru/config/config.header: -------------------------------------------------------------------------------- 1 | -- 工程根目录 2 | meiru_path = current_path 3 | 4 | ---------------------------------------------------- 5 | --skynet项目配置 6 | ---------------------------------------------------- 7 | skynet_path = meiru_path .. "skynet/" 8 | lua_cpath = skynet_path .. "luaclib/?.so" 9 | cpath = skynet_path .. "cservice/?.so" 10 | lualoader = skynet_path .. "lualib/loader.lua" 11 | snax = skynet_path .. "lualib/?.lua;" 12 | lua_path = skynet_path .. "lualib/?.lua;" 13 | luaservice = skynet_path .. "service/?.lua;" 14 | 15 | ---------------------------------------------------- 16 | --meiru项目配置 17 | ---------------------------------------------------- 18 | lua_path = lua_path .. meiru_path .. "lualib/?.lua;" 19 | luaservice = luaservice .. meiru_path .. "service/?.lua;" 20 | 21 | ---------------------------------------------------- 22 | --启动参数配置 23 | ---------------------------------------------------- 24 | thread = 8 25 | harbor = 0 26 | bootstrap = "snlua bootstrap" -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/include/test/btalloc.h: -------------------------------------------------------------------------------- 1 | /* btalloc() provides a mechanism for allocating via permuted backtraces. */ 2 | void *btalloc(size_t size, unsigned bits); 3 | 4 | #define btalloc_n_proto(n) \ 5 | void *btalloc_##n(size_t size, unsigned bits); 6 | btalloc_n_proto(0) 7 | btalloc_n_proto(1) 8 | 9 | #define btalloc_n_gen(n) \ 10 | void * \ 11 | btalloc_##n(size_t size, unsigned bits) { \ 12 | void *p; \ 13 | \ 14 | if (bits == 0) { \ 15 | p = mallocx(size, 0); \ 16 | } else { \ 17 | switch (bits & 0x1U) { \ 18 | case 0: \ 19 | p = (btalloc_0(size, bits >> 1)); \ 20 | break; \ 21 | case 1: \ 22 | p = (btalloc_1(size, bits >> 1)); \ 23 | break; \ 24 | default: not_reached(); \ 25 | } \ 26 | } \ 27 | /* Intentionally sabotage tail call optimization. */ \ 28 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); \ 29 | return p; \ 30 | } 31 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lpeg/lpcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lpcode.h,v 1.8 2016/09/15 17:46:13 roberto Exp $ 3 | */ 4 | 5 | #if !defined(lpcode_h) 6 | #define lpcode_h 7 | 8 | #include "lua.h" 9 | 10 | #include "lptypes.h" 11 | #include "lptree.h" 12 | #include "lpvm.h" 13 | 14 | int tocharset (TTree *tree, Charset *cs); 15 | int checkaux (TTree *tree, int pred); 16 | int fixedlen (TTree *tree); 17 | int hascaptures (TTree *tree); 18 | int lp_gc (lua_State *L); 19 | Instruction *compile (lua_State *L, Pattern *p); 20 | void realloccode (lua_State *L, Pattern *p, int nsize); 21 | int sizei (const Instruction *i); 22 | 23 | 24 | #define PEnullable 0 25 | #define PEnofail 1 26 | 27 | /* 28 | ** nofail(t) implies that 't' cannot fail with any input 29 | */ 30 | #define nofail(t) checkaux(t, PEnofail) 31 | 32 | /* 33 | ** (not nullable(t)) implies 't' cannot match without consuming 34 | ** something 35 | */ 36 | #define nullable(t) checkaux(t, PEnullable) 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Mark up Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/uniopen.lua: -------------------------------------------------------------------------------- 1 | 2 | -- Simple (and incomplete) Unicode I/O layer. 3 | 4 | local iconv = require("iconv") 5 | 6 | local m = { } 7 | local mti = { } 8 | local mt = { __index = mti } 9 | 10 | function m.open(fname, mode, tocharset, fromcharset) 11 | assert(mode == "r" or mode == "rb", "Only read modes are supported yet") 12 | local cd = assert(iconv.new(tocharset, fromcharset), "Bad charset") 13 | local fp = io.open(fname, mode) 14 | if not fp then 15 | return nil 16 | end 17 | local o = { fp = fp, cd = cd } 18 | setmetatable(o, mt) 19 | return o; 20 | end 21 | 22 | function mti.read(fp, mod) 23 | assert(fp and fp.fp and fp.cd, "Bad file descriptor") 24 | local ret = fp.fp:read(mod) 25 | if ret then 26 | return fp.cd:iconv(ret) -- returns: string, error code 27 | else 28 | return nil 29 | end 30 | end 31 | 32 | function mti.close(fp) 33 | assert(fp and fp.fp, "Bad file descriptor") 34 | fp.fp:close() 35 | end 36 | 37 | return m 38 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/skynet/queue.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local coroutine = coroutine 3 | local xpcall = xpcall 4 | local traceback = debug.traceback 5 | local table = table 6 | 7 | function skynet.queue() 8 | local current_thread 9 | local ref = 0 10 | local thread_queue = {} 11 | 12 | local function xpcall_ret(ok, ...) 13 | ref = ref - 1 14 | if ref == 0 then 15 | current_thread = table.remove(thread_queue,1) 16 | if current_thread then 17 | skynet.wakeup(current_thread) 18 | end 19 | end 20 | assert(ok, (...)) 21 | return ... 22 | end 23 | 24 | return function(f, ...) 25 | local thread = coroutine.running() 26 | if current_thread and current_thread ~= thread then 27 | table.insert(thread_queue, thread) 28 | skynet.wait() 29 | assert(ref == 0) -- current_thread == thread 30 | end 31 | current_thread = thread 32 | 33 | ref = ref + 1 34 | return xpcall_ret(xpcall(f, traceback, ...)) 35 | end 36 | end 37 | 38 | return skynet.queue 39 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/com/comsession.lua: -------------------------------------------------------------------------------- 1 | local Com = include("com", ...) 2 | local Cookie = include(".util.cookie", ...) 3 | local Session = include(".util.session", ...) 4 | 5 | ---------------------------------------------- 6 | --ComSession 7 | ---------------------------------------------- 8 | local ComSession = class("ComSession", Com) 9 | 10 | function ComSession:ctor() 11 | end 12 | 13 | function ComSession:match(req, res) 14 | if req.session then 15 | return 16 | end 17 | if not req.cookies then 18 | if not req.get('cookie') then 19 | req.cookies = {} 20 | req.signcookies = {} 21 | else 22 | local session_secret = req.app.get("session_secret") or "meiru" 23 | local cookies, signcookies = Cookie.cookie_decode(req.get('cookie'), session_secret) 24 | req.cookies = cookies or {} 25 | req.signcookies = signcookies or {} 26 | end 27 | end 28 | req.session = Session(req, res) 29 | req.sessionid = req.session.sessionid 30 | end 31 | 32 | 33 | 34 | return ComSession 35 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/test_hooks.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_TEST_HOOKS_H 2 | #define JEMALLOC_INTERNAL_TEST_HOOKS_H 3 | 4 | extern JEMALLOC_EXPORT void (*test_hooks_arena_new_hook)(); 5 | extern JEMALLOC_EXPORT void (*test_hooks_libc_hook)(); 6 | 7 | #define JEMALLOC_HOOK(fn, hook) ((void)(hook != NULL && (hook(), 0)), fn) 8 | 9 | #define open JEMALLOC_HOOK(open, test_hooks_libc_hook) 10 | #define read JEMALLOC_HOOK(read, test_hooks_libc_hook) 11 | #define write JEMALLOC_HOOK(write, test_hooks_libc_hook) 12 | #define readlink JEMALLOC_HOOK(readlink, test_hooks_libc_hook) 13 | #define close JEMALLOC_HOOK(close, test_hooks_libc_hook) 14 | #define creat JEMALLOC_HOOK(creat, test_hooks_libc_hook) 15 | #define secure_getenv JEMALLOC_HOOK(secure_getenv, test_hooks_libc_hook) 16 | /* Note that this is undef'd and re-define'd in src/prof.c. */ 17 | #define _Unwind_Backtrace JEMALLOC_HOOK(_Unwind_Backtrace, test_hooks_libc_hook) 18 | 19 | #endif /* JEMALLOC_INTERNAL_TEST_HOOKS_H */ 20 | -------------------------------------------------------------------------------- /test/assets/view/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <% if topic then %> 9 | <%= topic.title %> - <%= config.name %> 10 | <% elseif pageTitle then %> 11 | <%= pageTitle %> - <%= config.name %> 12 | <% else %> 13 | <%= config.description %> 14 | <% end %> 15 | 16 | 17 |

It's Work!!!

18 |

Welcome to meiru framework!!!

19 | 管理后台 20 | 21 |
22 | 25 |
26 | <%- body %> 27 |
28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /meiru/skynet/service/dbg.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local cmd = { ... } 4 | 5 | local function format_table(t) 6 | local index = {} 7 | for k in pairs(t) do 8 | table.insert(index, k) 9 | end 10 | table.sort(index) 11 | local result = {} 12 | for _,v in ipairs(index) do 13 | table.insert(result, string.format("%s:%s",v,tostring(t[v]))) 14 | end 15 | return table.concat(result,"\t") 16 | end 17 | 18 | local function dump_line(key, value) 19 | if type(value) == "table" then 20 | print(key, format_table(value)) 21 | else 22 | print(key,tostring(value)) 23 | end 24 | end 25 | 26 | local function dump_list(list) 27 | local index = {} 28 | for k in pairs(list) do 29 | table.insert(index, k) 30 | end 31 | table.sort(index) 32 | for _,v in ipairs(index) do 33 | dump_line(v, list[v]) 34 | end 35 | end 36 | 37 | skynet.start(function() 38 | local list = skynet.call(".launcher","lua", table.unpack(cmd)) 39 | if list then 40 | dump_list(list) 41 | end 42 | skynet.exit() 43 | end) -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | sudo: false 4 | 5 | env: 6 | - LUA="lua 5.1" 7 | - LUA="lua 5.2" 8 | - LUA="lua 5.3" 9 | - LUA="luajit 2.0" 10 | - LUA="luajit 2.1" 11 | 12 | before_install: 13 | - pip install --user cpp-coveralls hererocks 14 | - hererocks env --$LUA --luarocks latest 15 | - export PATH="$PWD/env/bin:$PATH" 16 | - luarocks install lua-path 17 | - luarocks install dkjson 18 | - luarocks install luacov 19 | # install luacov-coveralls, but avoid installing luafilesystem 20 | - luarocks install luacov-coveralls --server=https://luarocks.org/dev --deps-mode=none 21 | 22 | install: 23 | - luarocks make CFLAGS="-O2 -fPIC -ftest-coverage -fprofile-arcs" LIBFLAG="-shared --coverage" 24 | 25 | script: 26 | - lua -lluacov tests/test.lua 27 | 28 | after_success: 29 | - coveralls -b . -i src --dump c.report.json 30 | - luacov-coveralls -j c.report.json -v 31 | 32 | notifications: 33 | email: 34 | on_success: change 35 | on_failure: always 36 | -------------------------------------------------------------------------------- /meiru/template/assets/view/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <% if topic then %> 9 | <%= topic.title %> - <%= config.name %> 10 | <% elseif pageTitle then %> 11 | <%= pageTitle %> - <%= config.name %> 12 | <% else %> 13 | <%= config.description %> 14 | <% end %> 15 | 16 | 17 |

It's Work!!!

18 |

Welcome to meiru framework!!!

19 | 管理后台 20 | 21 |
22 | 25 |
26 | <%- body %> 27 |
28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-cjson/tests/example5.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "header": "SVG Viewer", 3 | "items": [ 4 | {"id": "Open"}, 5 | {"id": "OpenNew", "label": "Open New"}, 6 | null, 7 | {"id": "ZoomIn", "label": "Zoom In"}, 8 | {"id": "ZoomOut", "label": "Zoom Out"}, 9 | {"id": "OriginalView", "label": "Original View"}, 10 | null, 11 | {"id": "Quality"}, 12 | {"id": "Pause"}, 13 | {"id": "Mute"}, 14 | null, 15 | {"id": "Find", "label": "Find..."}, 16 | {"id": "FindAgain", "label": "Find Again"}, 17 | {"id": "Copy"}, 18 | {"id": "CopyAgain", "label": "Copy Again"}, 19 | {"id": "CopySVG", "label": "Copy SVG"}, 20 | {"id": "ViewSVG", "label": "View SVG"}, 21 | {"id": "ViewSource", "label": "View Source"}, 22 | {"id": "SaveAs", "label": "Save As"}, 23 | null, 24 | {"id": "Help"}, 25 | {"id": "About", "label": "About Adobe CVG Viewer..."} 26 | ] 27 | }} 28 | -------------------------------------------------------------------------------- /meiru/skynet/examples/simpledb.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | require "skynet.manager" -- import skynet.register 3 | local db = {} 4 | 5 | local command = {} 6 | 7 | function command.GET(key) 8 | return db[key] 9 | end 10 | 11 | function command.SET(key, value) 12 | local last = db[key] 13 | db[key] = value 14 | return last 15 | end 16 | 17 | skynet.start(function() 18 | skynet.dispatch("lua", function(session, address, cmd, ...) 19 | cmd = cmd:upper() 20 | if cmd == "PING" then 21 | assert(session == 0) 22 | local str = (...) 23 | if #str > 20 then 24 | str = str:sub(1,20) .. "...(" .. #str .. ")" 25 | end 26 | skynet.error(string.format("%s ping %s", skynet.address(address), str)) 27 | return 28 | end 29 | local f = command[cmd] 30 | if f then 31 | skynet.ret(skynet.pack(f(...))) 32 | else 33 | error(string.format("Unknown command %s", tostring(cmd))) 34 | end 35 | end) 36 | -- skynet.traceproto("lua", false) -- true off tracelog 37 | skynet.register "SIMPLEDB" 38 | end) 39 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua-iconv/debian/changelog: -------------------------------------------------------------------------------- 1 | lua-iconv (7-1) unstable; urgency=low 2 | 3 | * Update package for lua-iconv 7 + Lua-5.2 4 | 5 | -- Alexandre Erwin Ittner Sun, 06 May 2012 22:35:22 -0300 6 | 7 | lua-iconv (6-3) unstable; urgency=low 8 | 9 | * debian/control: Conflicts, Provides, and Replaces lua-iconv 10 | (Closes: #557052) 11 | 12 | -- Jon Bernard Fri, 20 Nov 2009 18:58:12 -0600 13 | 14 | lua-iconv (6-2) unstable; urgency=low 15 | 16 | * debian/control: update package name to conform to lua standard 17 | (Closes: #544958) 18 | * debian/control: add Vcs fields 19 | * debian/control: update package description 20 | * debian/watch: look for new upstream releases on luaforge (Closes: #544960) 21 | 22 | -- Jon Bernard Wed, 28 Oct 2009 11:58:00 -0400 23 | 24 | lua-iconv (6-1) unstable; urgency=low 25 | 26 | * Initial release (Closes: #540298) 27 | 28 | -- Jon Bernard Sun, 02 Aug 2009 13:50:50 -0400 29 | -------------------------------------------------------------------------------- /meiru/skynet/test/testecho.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local mode = ... 4 | 5 | if mode == "slave" then 6 | 7 | skynet.start(function() 8 | skynet.dispatch("lua", function(_,_, ...) 9 | skynet.ret(skynet.pack(...)) 10 | end) 11 | end) 12 | 13 | else 14 | 15 | skynet.start(function() 16 | local slave = skynet.newservice(SERVICE_NAME, "slave") 17 | local n = 100000 18 | local start = skynet.now() 19 | print("call salve", n, "times in queue") 20 | for i=1,n do 21 | skynet.call(slave, "lua") 22 | end 23 | print("qps = ", n/ (skynet.now() - start) * 100) 24 | 25 | start = skynet.now() 26 | 27 | local worker = 10 28 | local task = n/worker 29 | print("call salve", n, "times in parallel, worker = ", worker) 30 | 31 | for i=1,worker do 32 | skynet.fork(function() 33 | for i=1,task do 34 | skynet.call(slave, "lua") 35 | end 36 | worker = worker -1 37 | if worker == 0 then 38 | print("qps = ", n/ (skynet.now() - start) * 100) 39 | end 40 | end) 41 | end 42 | end) 43 | 44 | end 45 | -------------------------------------------------------------------------------- /meiru/skynet/examples/simplemonitor.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | -- It's a simple service exit monitor, you can do something more when a service exit. 4 | 5 | local service_map = {} 6 | 7 | skynet.register_protocol { 8 | name = "client", 9 | id = skynet.PTYPE_CLIENT, -- PTYPE_CLIENT = 3 10 | unpack = function() end, 11 | dispatch = function(_, address) 12 | local w = service_map[address] 13 | if w then 14 | for watcher in pairs(w) do 15 | skynet.redirect(watcher, address, "error", 0, "") 16 | end 17 | service_map[address] = false 18 | end 19 | end 20 | } 21 | 22 | local function monitor(session, watcher, command, service) 23 | assert(command, "WATCH") 24 | local w = service_map[service] 25 | if not w then 26 | if w == false then 27 | skynet.ret(skynet.pack(false)) 28 | return 29 | end 30 | w = {} 31 | service_map[service] = w 32 | end 33 | w[watcher] = true 34 | skynet.ret(skynet.pack(true)) 35 | end 36 | 37 | skynet.start(function() 38 | skynet.dispatch("lua", monitor) 39 | end) 40 | -------------------------------------------------------------------------------- /meiru/lualib/meiru/node/root.lua: -------------------------------------------------------------------------------- 1 | local Node = include("node", ...) 2 | 3 | local Root = class("Root", Node) 4 | 5 | function Root:ctor(name, meiru) 6 | Node.ctor(self, name, meiru) 7 | end 8 | 9 | function Root:add_com(com) 10 | assert(false) 11 | end 12 | 13 | function Root:add_child(child) 14 | assert(child.name == "node_req" or child.name == "node_res") 15 | Node.add_child(self, child) 16 | end 17 | 18 | function Root:footprint(depth) 19 | depth = (depth or 0)+1 20 | local rets = {} 21 | if self.path then 22 | table.insert(rets, string.rep("++", depth) .. self.name..":"..self.path) 23 | else 24 | table.insert(rets, string.rep("++", depth) .. self.name) 25 | end 26 | if self.children then 27 | for _,child in ipairs(self.children) do 28 | local ret = child:footprint(depth) 29 | if ret then 30 | table.insert(rets, ret) 31 | end 32 | end 33 | end 34 | return table.concat(rets, "\n") 35 | end 36 | 37 | return Root 38 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_env.c: -------------------------------------------------------------------------------- 1 | #include "skynet.h" 2 | #include "skynet_env.h" 3 | #include "spinlock.h" 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | struct skynet_env { 12 | struct spinlock lock; 13 | lua_State *L; 14 | }; 15 | 16 | static struct skynet_env *E = NULL; 17 | 18 | const char * 19 | skynet_getenv(const char *key) { 20 | SPIN_LOCK(E) 21 | 22 | lua_State *L = E->L; 23 | 24 | lua_getglobal(L, key); 25 | const char * result = lua_tostring(L, -1); 26 | lua_pop(L, 1); 27 | 28 | SPIN_UNLOCK(E) 29 | 30 | return result; 31 | } 32 | 33 | void 34 | skynet_setenv(const char *key, const char *value) { 35 | SPIN_LOCK(E) 36 | 37 | lua_State *L = E->L; 38 | lua_getglobal(L, key); 39 | assert(lua_isnil(L, -1)); 40 | lua_pop(L,1); 41 | lua_pushstring(L,value); 42 | lua_setglobal(L,key); 43 | 44 | SPIN_UNLOCK(E) 45 | } 46 | 47 | void 48 | skynet_env_init() { 49 | E = skynet_malloc(sizeof(*E)); 50 | SPIN_INIT(E) 51 | E->L = luaL_newstate(); 52 | } 53 | -------------------------------------------------------------------------------- /meiru/skynet/test/testresponse.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local mode = ... 4 | 5 | if mode == "TICK" then 6 | -- this service whould response the request every 1s. 7 | 8 | local response_queue = {} 9 | 10 | local function response() 11 | while true do 12 | skynet.sleep(100) -- sleep 1s 13 | for k,v in ipairs(response_queue) do 14 | v(true, skynet.now()) -- true means succ, false means error 15 | response_queue[k] = nil 16 | end 17 | end 18 | end 19 | 20 | skynet.start(function() 21 | skynet.fork(response) 22 | skynet.dispatch("lua", function() 23 | table.insert(response_queue, skynet.response()) 24 | end) 25 | end) 26 | 27 | else 28 | 29 | local function request(tick, i) 30 | print(i, "call", skynet.now()) 31 | print(i, "response", skynet.call(tick, "lua")) 32 | print(i, "end", skynet.now()) 33 | end 34 | 35 | skynet.start(function() 36 | local tick = skynet.newservice(SERVICE_NAME, "TICK") 37 | 38 | for i=1,5 do 39 | skynet.fork(request, tick, i) 40 | skynet.sleep(10) 41 | end 42 | end) 43 | 44 | end -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/prof_idump.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | static bool did_prof_dump_open; 4 | 5 | static int 6 | prof_dump_open_intercept(bool propagate_err, const char *filename) { 7 | int fd; 8 | 9 | did_prof_dump_open = true; 10 | 11 | fd = open("/dev/null", O_WRONLY); 12 | assert_d_ne(fd, -1, "Unexpected open() failure"); 13 | 14 | return fd; 15 | } 16 | 17 | TEST_BEGIN(test_idump) { 18 | bool active; 19 | void *p; 20 | 21 | test_skip_if(!config_prof); 22 | 23 | active = true; 24 | assert_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active, 25 | sizeof(active)), 0, 26 | "Unexpected mallctl failure while activating profiling"); 27 | 28 | prof_dump_open = prof_dump_open_intercept; 29 | 30 | did_prof_dump_open = false; 31 | p = mallocx(1, 0); 32 | assert_ptr_not_null(p, "Unexpected mallocx() failure"); 33 | dallocx(p, 0); 34 | assert_true(did_prof_dump_open, "Expected a profile dump"); 35 | } 36 | TEST_END 37 | 38 | int 39 | main(void) { 40 | return test( 41 | test_idump); 42 | } 43 | -------------------------------------------------------------------------------- /meiru/skynet/platform.mk: -------------------------------------------------------------------------------- 1 | PLAT ?= none 2 | PLATS = linux freebsd macosx 3 | 4 | CC ?= gcc 5 | 6 | .PHONY : none $(PLATS) clean all cleanall 7 | 8 | #ifneq ($(PLAT), none) 9 | 10 | .PHONY : default 11 | 12 | default : 13 | $(MAKE) $(PLAT) 14 | 15 | #endif 16 | 17 | none : 18 | @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" 19 | @echo " $(PLATS)" 20 | 21 | SKYNET_LIBS := -lpthread -lm 22 | SHARED := -fPIC --shared 23 | EXPORT := -Wl,-E 24 | 25 | linux : PLAT = linux 26 | macosx : PLAT = macosx 27 | freebsd : PLAT = freebsd 28 | 29 | macosx : SHARED := -fPIC -dynamiclib -Wl,-undefined,dynamic_lookup 30 | macosx : EXPORT := 31 | macosx linux : SKYNET_LIBS += -ldl 32 | linux freebsd : SKYNET_LIBS += -lrt 33 | 34 | # Turn off jemalloc and malloc hook on macosx 35 | 36 | macosx : MALLOC_STATICLIB := 37 | macosx : SKYNET_DEFINES :=-DNOUSE_JEMALLOC 38 | 39 | linux macosx freebsd : 40 | $(MAKE) all PLAT=$@ SKYNET_LIBS="$(SKYNET_LIBS)" SHARED="$(SHARED)" EXPORT="$(EXPORT)" MALLOC_STATICLIB="$(MALLOC_STATICLIB)" SKYNET_DEFINES="$(SKYNET_DEFINES)" 41 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/slab.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_arena_slab_regind) { 4 | szind_t binind; 5 | 6 | for (binind = 0; binind < SC_NBINS; binind++) { 7 | size_t regind; 8 | extent_t slab; 9 | const bin_info_t *bin_info = &bin_infos[binind]; 10 | extent_init(&slab, NULL, mallocx(bin_info->slab_size, 11 | MALLOCX_LG_ALIGN(LG_PAGE)), bin_info->slab_size, true, 12 | binind, 0, extent_state_active, false, true, true); 13 | assert_ptr_not_null(extent_addr_get(&slab), 14 | "Unexpected malloc() failure"); 15 | for (regind = 0; regind < bin_info->nregs; regind++) { 16 | void *reg = (void *)((uintptr_t)extent_addr_get(&slab) + 17 | (bin_info->reg_size * regind)); 18 | assert_zu_eq(arena_slab_regind(&slab, binind, reg), 19 | regind, 20 | "Incorrect region index computed for size %zu", 21 | bin_info->reg_size); 22 | } 23 | free(extent_addr_get(&slab)); 24 | } 25 | } 26 | TEST_END 27 | 28 | int 29 | main(void) { 30 | return test( 31 | test_arena_slab_regind); 32 | } 33 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/base_externs.h: -------------------------------------------------------------------------------- 1 | #ifndef JEMALLOC_INTERNAL_BASE_EXTERNS_H 2 | #define JEMALLOC_INTERNAL_BASE_EXTERNS_H 3 | 4 | extern metadata_thp_mode_t opt_metadata_thp; 5 | extern const char *metadata_thp_mode_names[]; 6 | 7 | base_t *b0get(void); 8 | base_t *base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks); 9 | void base_delete(tsdn_t *tsdn, base_t *base); 10 | extent_hooks_t *base_extent_hooks_get(base_t *base); 11 | extent_hooks_t *base_extent_hooks_set(base_t *base, 12 | extent_hooks_t *extent_hooks); 13 | void *base_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment); 14 | extent_t *base_alloc_extent(tsdn_t *tsdn, base_t *base); 15 | void base_stats_get(tsdn_t *tsdn, base_t *base, size_t *allocated, 16 | size_t *resident, size_t *mapped, size_t *n_thp); 17 | void base_prefork(tsdn_t *tsdn, base_t *base); 18 | void base_postfork_parent(tsdn_t *tsdn, base_t *base); 19 | void base_postfork_child(tsdn_t *tsdn, base_t *base); 20 | bool base_boot(tsdn_t *tsdn); 21 | 22 | #endif /* JEMALLOC_INTERNAL_BASE_EXTERNS_H */ 23 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/lua/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /meiru/skynet/test/pingserver.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local queue = require "skynet.queue" 3 | local snax = require "skynet.snax" 4 | 5 | local i = 0 6 | local hello = "hello" 7 | 8 | function response.ping(hello) 9 | skynet.sleep(100) 10 | return hello 11 | end 12 | 13 | -- response.sleep and accept.hello share one lock 14 | local lock 15 | 16 | function accept.sleep(queue, n) 17 | if queue then 18 | lock( 19 | function() 20 | print("queue=",queue, n) 21 | skynet.sleep(n) 22 | end) 23 | else 24 | print("queue=",queue, n) 25 | skynet.sleep(n) 26 | end 27 | end 28 | 29 | function accept.hello() 30 | lock(function() 31 | i = i + 1 32 | print (i, hello) 33 | end) 34 | end 35 | 36 | function accept.exit(...) 37 | snax.exit(...) 38 | end 39 | 40 | function response.error() 41 | error "throw an error" 42 | end 43 | 44 | function init( ... ) 45 | print ("ping server start:", ...) 46 | snax.enablecluster() -- enable cluster call 47 | -- init queue 48 | lock = queue() 49 | end 50 | 51 | function exit(...) 52 | print ("ping server exit:", ...) 53 | end 54 | -------------------------------------------------------------------------------- /meiru/skynet/test/testservice/kvdb.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local service = require "skynet.service" 3 | 4 | local kvdb = {} 5 | 6 | function kvdb.get(db,key) 7 | return skynet.call(service.query(db), "lua", "get", key) 8 | end 9 | 10 | function kvdb.set(db,key, value) 11 | skynet.call(service.query(db), "lua", "set", key , value) 12 | end 13 | 14 | -- this function will be injected into an unique service, so don't refer any upvalues 15 | local function service_mainfunc(...) 16 | local skynet = require "skynet" 17 | 18 | skynet.error(...) -- (...) passed from service.new 19 | 20 | local db = {} 21 | 22 | local command = {} 23 | 24 | function command.get(key) 25 | return db[key] 26 | end 27 | 28 | function command.set(key, value) 29 | db[key] = value 30 | end 31 | 32 | -- skynet.start is compatible 33 | skynet.dispatch("lua", function(session, address, cmd, ...) 34 | skynet.ret(skynet.pack(command[cmd](...))) 35 | end) 36 | end 37 | 38 | function kvdb.new(db) 39 | return service.new(db, service_mainfunc, "Service Init") 40 | end 41 | 42 | return kvdb 43 | -------------------------------------------------------------------------------- /meiru/skynet/service/clusterproxy.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local cluster = require "skynet.cluster" 3 | require "skynet.manager" -- inject skynet.forward_type 4 | 5 | local node, address = ... 6 | 7 | skynet.register_protocol { 8 | name = "system", 9 | id = skynet.PTYPE_SYSTEM, 10 | unpack = function (...) return ... end, 11 | } 12 | 13 | local forward_map = { 14 | [skynet.PTYPE_SNAX] = skynet.PTYPE_SYSTEM, 15 | [skynet.PTYPE_LUA] = skynet.PTYPE_SYSTEM, 16 | [skynet.PTYPE_RESPONSE] = skynet.PTYPE_RESPONSE, -- don't free response message 17 | } 18 | 19 | skynet.forward_type( forward_map ,function() 20 | local clusterd = skynet.uniqueservice("clusterd") 21 | local n = tonumber(address) 22 | if n then 23 | address = n 24 | end 25 | local sender = skynet.call(clusterd, "lua", "sender", node) 26 | skynet.dispatch("system", function (session, source, msg, sz) 27 | if session == 0 then 28 | skynet.send(sender, "lua", "push", address, msg, sz) 29 | else 30 | skynet.ret(skynet.rawcall(sender, "lua", skynet.pack("req", address, msg, sz))) 31 | end 32 | end) 33 | end) 34 | -------------------------------------------------------------------------------- /meiru/config/config.demo: -------------------------------------------------------------------------------- 1 | include "config.header" 2 | 3 | --------------------------------------------------------------------- 4 | -- 启动配置 5 | --------------------------------------------------------------------- 6 | thread = 8 7 | harbor = 0 8 | bootstrap = "snlua bootstrap" 9 | --daemon = "./remote.pid" 10 | 11 | --logger = "./log/test.log" 12 | logpath = "." 13 | start = "main" 14 | maxclient = 20480 15 | 16 | ---------------------------------------------------- 17 | --test项目配置 18 | ---------------------------------------------------- 19 | dbgport = 8888 20 | httpport = 8080 21 | httpsport = 8081 22 | 23 | 24 | --test_path = current_path 25 | --lua_path = lua_path .. test_path .. "lualib/?.lua;" 26 | --luaservice = luaservice .. test_path .. "service/?.lua;" 27 | 28 | -- 集群配置 29 | --cluster = test_path .. "lualib/cluster/clustername.lua" 30 | 31 | -- 预加载文件 32 | --preload = test_path .. "lualib/preload/__preload.lua" 33 | 34 | -- 数据库配置 35 | --mysql = [[{host = '127.0.0.1',port = '3306',database = 'demo',username = 'root',password = '123456'}]] 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/test/unit/sc.c: -------------------------------------------------------------------------------- 1 | #include "test/jemalloc_test.h" 2 | 3 | TEST_BEGIN(test_update_slab_size) { 4 | sc_data_t data; 5 | memset(&data, 0, sizeof(data)); 6 | sc_data_init(&data); 7 | sc_t *tiny = &data.sc[0]; 8 | size_t tiny_size = (ZU(1) << tiny->lg_base) 9 | + (ZU(tiny->ndelta) << tiny->lg_delta); 10 | size_t pgs_too_big = (tiny_size * BITMAP_MAXBITS + PAGE - 1) / PAGE + 1; 11 | sc_data_update_slab_size(&data, tiny_size, tiny_size, (int)pgs_too_big); 12 | assert_zu_lt((size_t)tiny->pgs, pgs_too_big, "Allowed excessive pages"); 13 | 14 | sc_data_update_slab_size(&data, 1, 10 * PAGE, 1); 15 | for (int i = 0; i < data.nbins; i++) { 16 | sc_t *sc = &data.sc[i]; 17 | size_t reg_size = (ZU(1) << sc->lg_base) 18 | + (ZU(sc->ndelta) << sc->lg_delta); 19 | if (reg_size <= PAGE) { 20 | assert_d_eq(sc->pgs, 1, "Ignored valid page size hint"); 21 | } else { 22 | assert_d_gt(sc->pgs, 1, 23 | "Allowed invalid page size hint"); 24 | } 25 | } 26 | } 27 | TEST_END 28 | 29 | int 30 | main(void) { 31 | return test( 32 | test_update_slab_size); 33 | } 34 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/test.c: -------------------------------------------------------------------------------- 1 | #include "pbc.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #define COUNT 1000000 8 | 9 | #include "readfile.h" 10 | 11 | static void 12 | test(struct pbc_env *env) { 13 | int i; 14 | for(i=0; i", channel) 37 | channel:publish("Hello World") 38 | end) 39 | 40 | end -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/README: -------------------------------------------------------------------------------- 1 | jemalloc is a general purpose malloc(3) implementation that emphasizes 2 | fragmentation avoidance and scalable concurrency support. jemalloc first came 3 | into use as the FreeBSD libc allocator in 2005, and since then it has found its 4 | way into numerous applications that rely on its predictable behavior. In 2010 5 | jemalloc development efforts broadened to include developer support features 6 | such as heap profiling and extensive monitoring/tuning hooks. Modern jemalloc 7 | releases continue to be integrated back into FreeBSD, and therefore versatility 8 | remains critical. Ongoing development efforts trend toward making jemalloc 9 | among the best allocators for a broad range of demanding applications, and 10 | eliminating/mitigating weaknesses that have practical repercussions for real 11 | world applications. 12 | 13 | The COPYING file contains copyright and licensing information. 14 | 15 | The INSTALL file contains information on how to configure, build, and install 16 | jemalloc. 17 | 18 | The ChangeLog file contains a brief summary of changes for each release. 19 | 20 | URL: http://jemalloc.net/ 21 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/msvc/projects/vc2015/test_threads/test_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/msvc/projects/vc2017/test_threads/test_threads.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/skynet/service.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local service = {} 4 | local cache = {} 5 | local provider 6 | 7 | local function get_provider() 8 | provider = provider or skynet.uniqueservice "service_provider" 9 | return provider 10 | end 11 | 12 | local function check(func) 13 | local info = debug.getinfo(func, "u") 14 | assert(info.nups == 1) 15 | assert(debug.getupvalue(func,1) == "_ENV") 16 | end 17 | 18 | function service.new(name, mainfunc, ...) 19 | local p = get_provider() 20 | local addr, booting = skynet.call(p, "lua", "test", name) 21 | local address 22 | if addr then 23 | address = addr 24 | else 25 | if booting then 26 | address = skynet.call(p, "lua", "query", name) 27 | else 28 | check(mainfunc) 29 | local code = string.dump(mainfunc) 30 | address = skynet.call(p, "lua", "launch", name, code, ...) 31 | end 32 | end 33 | cache[name] = address 34 | return address 35 | end 36 | 37 | function service.query(name) 38 | if not cache[name] then 39 | cache[name] = skynet.call(get_provider(), "lua", "query", name) 40 | end 41 | return cache[name] 42 | end 43 | 44 | return service 45 | -------------------------------------------------------------------------------- /meiru/skynet/test/testdatasheet.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | 3 | local mode = ... 4 | 5 | local function dump(t, prefix) 6 | for k,v in pairs(t) do 7 | print(prefix, k, v) 8 | if type(v) == "table" then 9 | dump(v, prefix .. "." .. k) 10 | end 11 | end 12 | end 13 | 14 | if mode == "child" then 15 | 16 | local datasheet = require "skynet.datasheet" 17 | 18 | skynet.start(function() 19 | local t = datasheet.query("foobar") 20 | dump(t, "[CHILD]") 21 | 22 | skynet.sleep(100) 23 | skynet.exit() 24 | end) 25 | 26 | else 27 | 28 | local builder = require "skynet.datasheet.builder" 29 | local datasheet = require "skynet.datasheet" 30 | 31 | skynet.start(function() 32 | builder.new("foobar", {a = 1, b = 2 , c = {3} }) 33 | skynet.newservice(SERVICE_NAME, "child") 34 | local t = datasheet.query "foobar" 35 | local c = t.c 36 | dump(t, "[1]") 37 | builder.update("foobar", { b = 4, c = { 5 } }) 38 | print("sleep") 39 | skynet.sleep(100) 40 | dump(t, "[2]") 41 | dump(c, "[2.c]") 42 | builder.update("foobar", { a = 6, c = 7, d = 8 }) 43 | print("sleep") 44 | skynet.sleep(100) 45 | dump(t, "[3]") 46 | end) 47 | 48 | end -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 by Cloud Wu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/test/varint.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "varint.h" 4 | #include "pbc.h" 5 | 6 | static void 7 | dump(uint8_t buffer[10], int s) 8 | { 9 | int i; 10 | for (i=0;i 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /meiru/skynet/test/testsm.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local sharemap = require "skynet.sharemap" 3 | 4 | local mode = ... 5 | 6 | if mode == "slave" then 7 | --slave 8 | 9 | local function dump(reader) 10 | reader:update() 11 | print("x=", reader.x) 12 | print("y=", reader.y) 13 | print("s=", reader.s) 14 | end 15 | 16 | skynet.start(function() 17 | local reader 18 | skynet.dispatch("lua", function(_,_,cmd,...) 19 | if cmd == "init" then 20 | reader = sharemap.reader(...) 21 | else 22 | assert(cmd == "ping") 23 | dump(reader) 24 | end 25 | skynet.ret() 26 | end) 27 | end) 28 | 29 | else 30 | -- master 31 | skynet.start(function() 32 | -- register share type schema 33 | sharemap.register("./test/sharemap.sp") 34 | local slave = skynet.newservice(SERVICE_NAME, "slave") 35 | local writer = sharemap.writer("foobar", { x=0,y=0,s="hello" }) 36 | skynet.call(slave, "lua", "init", "foobar", writer:copy()) 37 | writer.x = 1 38 | writer:commit() 39 | skynet.call(slave, "lua", "ping") 40 | writer.y = 2 41 | writer:commit() 42 | skynet.call(slave, "lua", "ping") 43 | writer.s = "world" 44 | writer:commit() 45 | skynet.call(slave, "lua", "ping") 46 | end) 47 | 48 | end -------------------------------------------------------------------------------- /meiru/skynet/lualib/loader.lua: -------------------------------------------------------------------------------- 1 | local args = {} 2 | for word in string.gmatch(..., "%S+") do 3 | table.insert(args, word) 4 | end 5 | 6 | SERVICE_NAME = args[1] 7 | 8 | local main, pattern 9 | 10 | local err = {} 11 | for pat in string.gmatch(LUA_SERVICE, "([^;]+);*") do 12 | local filename = string.gsub(pat, "?", SERVICE_NAME) 13 | local f, msg = loadfile(filename) 14 | if not f then 15 | table.insert(err, msg) 16 | else 17 | pattern = pat 18 | main = f 19 | break 20 | end 21 | end 22 | 23 | if not main then 24 | error(table.concat(err, "\n")) 25 | end 26 | 27 | LUA_SERVICE = nil 28 | package.path , LUA_PATH = LUA_PATH 29 | package.cpath , LUA_CPATH = LUA_CPATH 30 | 31 | local service_path = string.match(pattern, "(.*/)[^/?]+$") 32 | 33 | if service_path then 34 | service_path = string.gsub(service_path, "?", args[1]) 35 | package.path = service_path .. "?.lua;" .. package.path 36 | SERVICE_PATH = service_path 37 | else 38 | local p = string.match(pattern, "(.*/).+$") 39 | SERVICE_PATH = p 40 | end 41 | 42 | if LUA_PRELOAD then 43 | local f = assert(loadfile(LUA_PRELOAD)) 44 | f(table.unpack(args)) 45 | LUA_PRELOAD = nil 46 | end 47 | 48 | main(select(2, table.unpack(args))) 49 | -------------------------------------------------------------------------------- /meiru/skynet/test/testhttp.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local httpc = require "http.httpc" 3 | local dns = require "skynet.dns" 4 | 5 | local function http_test(protocol) 6 | --httpc.dns() -- set dns server 7 | httpc.timeout = 100 -- set timeout 1 second 8 | print("GET baidu.com") 9 | protocol = protocol or "http" 10 | local respheader = {} 11 | local host = string.format("%s://baidu.com", protocol) 12 | print("geting... ".. host) 13 | local status, body = httpc.get(host, "/", respheader) 14 | print("[header] =====>") 15 | for k,v in pairs(respheader) do 16 | print(k,v) 17 | end 18 | print("[body] =====>", status) 19 | print(body) 20 | 21 | local respheader = {} 22 | local ip = dns.resolve "baidu.com" 23 | print(string.format("GET %s (baidu.com)", ip)) 24 | local status, body = httpc.get(host, "/", respheader, { host = "baidu.com" }) 25 | print(status) 26 | end 27 | 28 | 29 | local function main() 30 | dns.server() 31 | http_test("http") 32 | 33 | if not pcall(require,"ltls.c") then 34 | print "No ltls module, https is not supported" 35 | else 36 | http_test("https") 37 | end 38 | end 39 | 40 | skynet.start(function() 41 | print(pcall(main)) 42 | skynet.exit() 43 | end) 44 | -------------------------------------------------------------------------------- /meiru/skynet/lualib/md5.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- Modify version from https://github.com/keplerproject/md5 3 | ---------------------------------------------------------------------------- 4 | 5 | local core = require "md5.core" 6 | 7 | ---------------------------------------------------------------------------- 8 | -- @param k String with original message. 9 | -- @return String with the md5 hash value converted to hexadecimal digits 10 | 11 | function core.sumhexa (k) 12 | k = core.sum(k) 13 | return (string.gsub(k, ".", function (c) 14 | return string.format("%02x", string.byte(c)) 15 | end)) 16 | end 17 | 18 | local function get_ipad(c) 19 | return string.char(c:byte() ~ 0x36) 20 | end 21 | 22 | local function get_opad(c) 23 | return string.char(c:byte() ~ 0x5c) 24 | end 25 | 26 | function core.hmacmd5(data,key) 27 | if #key>64 then 28 | key=core.sum(key) 29 | key=key:sub(1,16) 30 | end 31 | local ipad_s=key:gsub(".", get_ipad)..string.rep("6",64-#key) 32 | local opad_s=key:gsub(".", get_opad)..string.rep("\\",64-#key) 33 | local istr=core.sum(ipad_s..data) 34 | local ostr=core.sumhexa(opad_s..istr) 35 | return ostr 36 | end 37 | 38 | return core 39 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/binding/lua/test.lua: -------------------------------------------------------------------------------- 1 | require "protobuf" 2 | 3 | addr = io.open("../../build/addressbook.pb","rb") 4 | buffer = addr:read "*a" 5 | addr:close() 6 | 7 | protobuf.register(buffer) 8 | 9 | t = protobuf.decode("google.protobuf.FileDescriptorSet", buffer) 10 | 11 | proto = t.file[1] 12 | 13 | print(proto.name) 14 | print(proto.package) 15 | 16 | message = proto.message_type 17 | 18 | for _,v in ipairs(message) do 19 | print(v.name) 20 | for _,v in ipairs(v.field) do 21 | print("\t".. v.name .. " ["..v.number.."] " .. v.label) 22 | end 23 | end 24 | 25 | addressbook = { 26 | name = "Alice", 27 | id = 12345, 28 | phone = { 29 | { number = "1301234567" }, 30 | { number = "87654321", type = "WORK" }, 31 | } 32 | } 33 | 34 | code = protobuf.encode("tutorial.Person", addressbook) 35 | 36 | decode = protobuf.decode("tutorial.Person" , code) 37 | 38 | print(decode.name) 39 | print(decode.id) 40 | for _,v in ipairs(decode.phone) do 41 | print("\t"..v.number, v.type) 42 | end 43 | 44 | phonebuf = protobuf.pack("tutorial.Person.PhoneNumber number","87654321") 45 | buffer = protobuf.pack("tutorial.Person name id phone", "Alice", 123, { phonebuf }) 46 | print(protobuf.unpack("tutorial.Person name id phone", buffer)) 47 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/jemalloc/include/jemalloc/internal/public_namespace.h: -------------------------------------------------------------------------------- 1 | #define je_aligned_alloc JEMALLOC_N(aligned_alloc) 2 | #define je_calloc JEMALLOC_N(calloc) 3 | #define je_dallocx JEMALLOC_N(dallocx) 4 | #define je_free JEMALLOC_N(free) 5 | #define je_mallctl JEMALLOC_N(mallctl) 6 | #define je_mallctlbymib JEMALLOC_N(mallctlbymib) 7 | #define je_mallctlnametomib JEMALLOC_N(mallctlnametomib) 8 | #define je_malloc JEMALLOC_N(malloc) 9 | #define je_malloc_conf JEMALLOC_N(malloc_conf) 10 | #define je_malloc_message JEMALLOC_N(malloc_message) 11 | #define je_malloc_stats_print JEMALLOC_N(malloc_stats_print) 12 | #define je_malloc_usable_size JEMALLOC_N(malloc_usable_size) 13 | #define je_mallocx JEMALLOC_N(mallocx) 14 | #define je_smallocx_b0b3e49a54ec29e32636f4577d9d5a896d67fd20 JEMALLOC_N(smallocx_b0b3e49a54ec29e32636f4577d9d5a896d67fd20) 15 | #define je_nallocx JEMALLOC_N(nallocx) 16 | #define je_posix_memalign JEMALLOC_N(posix_memalign) 17 | #define je_rallocx JEMALLOC_N(rallocx) 18 | #define je_realloc JEMALLOC_N(realloc) 19 | #define je_sallocx JEMALLOC_N(sallocx) 20 | #define je_sdallocx JEMALLOC_N(sdallocx) 21 | #define je_xallocx JEMALLOC_N(xallocx) 22 | #define je_memalign JEMALLOC_N(memalign) 23 | #define je_valloc JEMALLOC_N(valloc) 24 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/src/map.h: -------------------------------------------------------------------------------- 1 | #ifndef PROTOBUF_C_MAP_H 2 | #define PROTOBUF_C_MAP_H 3 | 4 | #include "alloc.h" 5 | 6 | struct map_ip; 7 | struct map_si; 8 | struct map_sp; 9 | 10 | struct map_kv { 11 | int id; 12 | void *pointer; 13 | }; 14 | 15 | struct map_si * _pbcM_si_new(struct map_kv * table, int size); 16 | int _pbcM_si_query(struct map_si *map, const char *key, int *result); 17 | void _pbcM_si_delete(struct map_si *map); 18 | 19 | struct map_ip * _pbcM_ip_new(struct map_kv * table, int size); 20 | struct map_ip * _pbcM_ip_combine(struct map_ip * a, struct map_ip * b); 21 | void * _pbcM_ip_query(struct map_ip * map, int id); 22 | void _pbcM_ip_delete(struct map_ip *map); 23 | 24 | struct map_sp * _pbcM_sp_new(int max, struct heap *h); 25 | void _pbcM_sp_insert(struct map_sp *map, const char *key, void * value); 26 | void * _pbcM_sp_query(struct map_sp *map, const char *key); 27 | void ** _pbcM_sp_query_insert(struct map_sp *map, const char *key); 28 | void _pbcM_sp_delete(struct map_sp *map); 29 | void _pbcM_sp_foreach(struct map_sp *map, void (*func)(void *p)); 30 | void _pbcM_sp_foreach_ud(struct map_sp *map, void (*func)(void *p, void *ud), void *ud); 31 | void * _pbcM_sp_next(struct map_sp *map, const char ** key); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/luafilesystem/README.md: -------------------------------------------------------------------------------- 1 | [![License](http://img.shields.io/badge/Licence-MIT-brightgreen.svg)](LICENSE) 2 | [![Build Status](https://travis-ci.org/keplerproject/luafilesystem.svg?branch=master)](https://travis-ci.org/keplerproject/luafilesystem) 3 | [![Build status](https://ci.appveyor.com/api/projects/status/y04s4ms7u16trw8e?svg=true)](https://ci.appveyor.com/project/ignacio/luafilesystem) 4 | [![Coverage Status](https://coveralls.io/repos/keplerproject/luafilesystem/badge.png)](https://coveralls.io/r/keplerproject/luafilesystem) 5 | 6 | # LuaFileSystem - File System Library for Lua 7 | 8 | Copyright 2003-2017 Kepler Project 9 | 10 | https://keplerproject.github.io/luafilesystem 11 | 12 | # Description 13 | 14 | LuaFileSystem is a Lua library developed to complement the set of functions 15 | related to file systems offered by the standard Lua distribution. 16 | 17 | LuaFileSystem offers a portable way to access the underlying directory structure and file attributes. 18 | LuaFileSystem is free software and uses the same license as Lua 5.x (MIT). 19 | 20 | # LuaRocks Installation 21 | 22 | ``` 23 | luarocks install luafilesystem 24 | ``` 25 | 26 | # Documentation 27 | 28 | Please check the documentation at doc/us/ for more information. 29 | -------------------------------------------------------------------------------- /meiru/skynet/3rd/pbc/binding/lua53/test.lua: -------------------------------------------------------------------------------- 1 | local protobuf = require "protobuf" 2 | 3 | addr = io.open("../../build/addressbook.pb","rb") 4 | buffer = addr:read "*a" 5 | addr:close() 6 | 7 | protobuf.register(buffer) 8 | 9 | t = protobuf.decode("google.protobuf.FileDescriptorSet", buffer) 10 | 11 | proto = t.file[1] 12 | 13 | print(proto.name) 14 | print(proto.package) 15 | 16 | message = proto.message_type 17 | 18 | for _,v in ipairs(message) do 19 | print(v.name) 20 | for _,v in ipairs(v.field) do 21 | print("\t".. v.name .. " ["..v.number.."] " .. v.label) 22 | end 23 | end 24 | 25 | addressbook = { 26 | name = "Alice", 27 | id = 12345, 28 | phone = { 29 | { number = "1301234567" }, 30 | { number = "87654321", type = "WORK" }, 31 | } 32 | } 33 | 34 | code = protobuf.encode("tutorial.Person", addressbook) 35 | 36 | decode = protobuf.decode("tutorial.Person" , code) 37 | 38 | print(decode.name) 39 | print(decode.id) 40 | for _,v in ipairs(decode.phone) do 41 | print("\t"..v.number, v.type) 42 | end 43 | 44 | phonebuf = protobuf.pack("tutorial.Person.PhoneNumber number","87654321") 45 | buffer = protobuf.pack("tutorial.Person name id phone", "Alice", 123, { phonebuf }) 46 | print(protobuf.unpack("tutorial.Person name id phone", buffer)) 47 | -------------------------------------------------------------------------------- /meiru/skynet/test/testtimeout.lua: -------------------------------------------------------------------------------- 1 | local skynet = require "skynet" 2 | local service = require "skynet.service" 3 | 4 | local function test_service() 5 | local skynet = require "skynet" 6 | 7 | skynet.start(function() 8 | skynet.dispatch("lua", function() 9 | skynet.error("Wait for 1s") 10 | skynet.sleep(100) -- response after 1s for any request 11 | skynet.ret() 12 | end) 13 | end) 14 | end 15 | 16 | local function timeout_call(ti, ...) 17 | local token = {} 18 | local ret 19 | 20 | skynet.fork(function(...) 21 | ret = table.pack(pcall(skynet.call, ...)) 22 | skynet.wakeup(token) 23 | end, ...) 24 | 25 | skynet.sleep(ti, token) 26 | if ret then 27 | if ret[1] then 28 | return table.unpack(ret, 1, ret.n) 29 | else 30 | error(ret[2]) 31 | end 32 | else 33 | -- timeout 34 | return false 35 | end 36 | end 37 | 38 | skynet.start(function() 39 | local test = service.new("testtimeout", test_service) 40 | skynet.error("1", skynet.now()) 41 | skynet.call(test, "lua") 42 | skynet.error("2", skynet.now()) 43 | skynet.error(timeout_call(50, test, "lua")) 44 | skynet.error("3", skynet.now()) 45 | skynet.error(timeout_call(150, test, "lua")) 46 | skynet.error("4", skynet.now()) 47 | skynet.exit() 48 | end) 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /meiru/skynet/skynet-src/skynet_monitor.c: -------------------------------------------------------------------------------- 1 | #include "skynet.h" 2 | 3 | #include "skynet_monitor.h" 4 | #include "skynet_server.h" 5 | #include "skynet.h" 6 | #include "atomic.h" 7 | 8 | #include 9 | #include 10 | 11 | struct skynet_monitor { 12 | int version; 13 | int check_version; 14 | uint32_t source; 15 | uint32_t destination; 16 | }; 17 | 18 | struct skynet_monitor * 19 | skynet_monitor_new() { 20 | struct skynet_monitor * ret = skynet_malloc(sizeof(*ret)); 21 | memset(ret, 0, sizeof(*ret)); 22 | return ret; 23 | } 24 | 25 | void 26 | skynet_monitor_delete(struct skynet_monitor *sm) { 27 | skynet_free(sm); 28 | } 29 | 30 | void 31 | skynet_monitor_trigger(struct skynet_monitor *sm, uint32_t source, uint32_t destination) { 32 | sm->source = source; 33 | sm->destination = destination; 34 | ATOM_INC(&sm->version); 35 | } 36 | 37 | void 38 | skynet_monitor_check(struct skynet_monitor *sm) { 39 | if (sm->version == sm->check_version) { 40 | if (sm->destination) { 41 | skynet_context_endless(sm->destination); 42 | skynet_error(NULL, "A message from [ :%08x ] to [ :%08x ] maybe in an endless loop (version = %d)", sm->source , sm->destination, sm->version); 43 | } 44 | } else { 45 | sm->check_version = sm->version; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /meiru/skynet/README.md: -------------------------------------------------------------------------------- 1 | ## ![skynet logo](https://github.com/cloudwu/skynet/wiki/image/skynet_metro.jpg) 2 | 3 | Skynet is a lightweight online game framework which can be used in many other fields. 4 | 5 | ## Build 6 | 7 | For Linux, install autoconf first for jemalloc: 8 | 9 | ``` 10 | git clone https://github.com/cloudwu/skynet.git 11 | cd skynet 12 | make 'PLATFORM' # PLATFORM can be linux, macosx, freebsd now 13 | ``` 14 | 15 | Or: 16 | 17 | ``` 18 | export PLAT=linux 19 | make 20 | ``` 21 | 22 | For FreeBSD , use gmake instead of make. 23 | 24 | ## Test 25 | 26 | Run these in different consoles: 27 | 28 | ``` 29 | ./skynet examples/config # Launch first skynet node (Gate server) and a skynet-master (see config for standalone option) 30 | ./3rd/lua/lua examples/client.lua # Launch a client, and try to input hello. 31 | ``` 32 | 33 | ## About Lua version 34 | 35 | Skynet now uses a modified version of lua 5.3.5 ( https://github.com/ejoy/lua/tree/skynet ) for multiple lua states. 36 | 37 | Official Lua versions can also be used as long as the Makefile is edited. 38 | 39 | ## How To Use (Sorry, currently only available in Chinese) 40 | 41 | * Read Wiki for documents https://github.com/cloudwu/skynet/wiki 42 | * The FAQ in wiki https://github.com/cloudwu/skynet/wiki/FAQ 43 | --------------------------------------------------------------------------------