asyncengine 0.0.1.testing
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +0 -0
- data/asyncengine.gemspec +26 -0
- data/ext/asyncengine_ext/asyncengine_ruby.c +82 -0
- data/ext/asyncengine_ext/extconf.rb +47 -0
- data/ext/asyncengine_ext/libuv/AUTHORS +45 -0
- data/ext/asyncengine_ext/libuv/LICENSE +42 -0
- data/ext/asyncengine_ext/libuv/Makefile +119 -0
- data/ext/asyncengine_ext/libuv/README.md +88 -0
- data/ext/asyncengine_ext/libuv/build/gcc_version.py +20 -0
- data/ext/asyncengine_ext/libuv/common.gypi +176 -0
- data/ext/asyncengine_ext/libuv/config-mingw.mk +61 -0
- data/ext/asyncengine_ext/libuv/config-unix.mk +173 -0
- data/ext/asyncengine_ext/libuv/gyp_uv +60 -0
- data/ext/asyncengine_ext/libuv/include/ares.h +591 -0
- data/ext/asyncengine_ext/libuv/include/ares_version.h +24 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/eio.h +403 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/ev.h +838 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/ngx-queue.h +106 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/tree.h +768 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/uv-unix.h +256 -0
- data/ext/asyncengine_ext/libuv/include/uv-private/uv-win.h +458 -0
- data/ext/asyncengine_ext/libuv/include/uv.h +1556 -0
- data/ext/asyncengine_ext/libuv/src/ares/AUTHORS +37 -0
- data/ext/asyncengine_ext/libuv/src/ares/CHANGES +1218 -0
- data/ext/asyncengine_ext/libuv/src/ares/CMakeLists.txt +22 -0
- data/ext/asyncengine_ext/libuv/src/ares/NEWS +21 -0
- data/ext/asyncengine_ext/libuv/src/ares/README +60 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.cares +13 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.msvc +142 -0
- data/ext/asyncengine_ext/libuv/src/ares/README.node +21 -0
- data/ext/asyncengine_ext/libuv/src/ares/RELEASE-NOTES +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/TODO +23 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__close_sockets.c +66 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__get_hostent.c +263 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__read_line.c +71 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares__timeval.c +111 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_cancel.c +63 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_data.c +190 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_data.h +65 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_destroy.c +105 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_dns.h +90 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_expand_name.c +200 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_expand_string.c +75 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_fds.c +63 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_free_hostent.c +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_free_string.c +25 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getenv.c +30 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getenv.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_gethostbyaddr.c +301 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_gethostbyname.c +523 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getnameinfo.c +427 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getopt.c +122 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getopt.h +53 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_getsock.c +72 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_init.c +1809 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_iphlpapi.h +221 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_ipv6.h +78 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_library_init.c +142 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_library_init.h +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_llist.c +86 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_llist.h +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_mkquery.c +195 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_nowarn.c +181 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_nowarn.h +55 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_options.c +248 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_a_reply.c +263 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_aaaa_reply.c +259 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_mx_reply.c +170 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_ns_reply.c +182 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_ptr_reply.c +217 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_srv_reply.c +179 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_parse_txt_reply.c +201 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_platform.c +11035 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_platform.h +43 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_private.h +355 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_process.c +1295 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_query.c +183 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_rules.h +144 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_search.c +321 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_send.c +134 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_setup.h +199 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strcasecmp.c +66 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strcasecmp.h +30 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strdup.c +42 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strdup.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_strerror.c +56 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_timeout.c +80 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_version.c +11 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_writev.c +79 -0
- data/ext/asyncengine_ext/libuv/src/ares/ares_writev.h +36 -0
- data/ext/asyncengine_ext/libuv/src/ares/bitncmp.c +59 -0
- data/ext/asyncengine_ext/libuv/src/ares/bitncmp.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_cygwin/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_darwin/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_freebsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_linux/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_netbsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_openbsd/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_sunos/ares_config.h +512 -0
- data/ext/asyncengine_ext/libuv/src/ares/config_win32/ares_config.h +369 -0
- data/ext/asyncengine_ext/libuv/src/ares/get_ver.awk +35 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_net_pton.c +451 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_net_pton.h +31 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_ntop.c +208 -0
- data/ext/asyncengine_ext/libuv/src/ares/inet_ntop.h +26 -0
- data/ext/asyncengine_ext/libuv/src/ares/nameser.h +203 -0
- data/ext/asyncengine_ext/libuv/src/ares/setup_once.h +504 -0
- data/ext/asyncengine_ext/libuv/src/ares/windows_port.c +22 -0
- data/ext/asyncengine_ext/libuv/src/unix/async.c +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/cares.c +194 -0
- data/ext/asyncengine_ext/libuv/src/unix/check.c +80 -0
- data/ext/asyncengine_ext/libuv/src/unix/core.c +588 -0
- data/ext/asyncengine_ext/libuv/src/unix/cygwin.c +84 -0
- data/ext/asyncengine_ext/libuv/src/unix/darwin.c +341 -0
- data/ext/asyncengine_ext/libuv/src/unix/dl.c +91 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/Changes +63 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/LICENSE +36 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/Makefile.am +15 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/aclocal.m4 +8957 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/autogen.sh +3 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config.h.in +86 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_cygwin.h +80 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_darwin.h +141 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_freebsd.h +81 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_linux.h +94 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_netbsd.h +81 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_openbsd.h +137 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/config_sunos.h +84 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/configure.ac +22 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/demo.c +194 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/ecb.h +370 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.3 +3428 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.c +2593 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/eio.pod +969 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/libeio.m4 +195 -0
- data/ext/asyncengine_ext/libuv/src/unix/eio/xthread.h +164 -0
- data/ext/asyncengine_ext/libuv/src/unix/error.c +98 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Changes +388 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/LICENSE +36 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Makefile.am +18 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/Makefile.in +771 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/README +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/aclocal.m4 +8957 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/autogen.sh +6 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.guess +1526 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.h.in +125 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config.sub +1658 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_cygwin.h +123 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_darwin.h +122 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_freebsd.h +120 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_linux.h +141 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_netbsd.h +120 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_openbsd.h +126 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/config_sunos.h +122 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/configure +13037 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/configure.ac +18 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/depcomp +630 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev++.h +816 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.3 +5311 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.c +3921 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev.pod +5243 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_epoll.c +266 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_kqueue.c +235 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_poll.c +148 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_port.c +179 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_select.c +310 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_vars.h +203 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_win32.c +153 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ev_wrap.h +196 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/event.c +402 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/event.h +170 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/install-sh +294 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/libev.m4 +39 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/ltmain.sh +8413 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/missing +336 -0
- data/ext/asyncengine_ext/libuv/src/unix/ev/mkinstalldirs +111 -0
- data/ext/asyncengine_ext/libuv/src/unix/freebsd.c +312 -0
- data/ext/asyncengine_ext/libuv/src/unix/fs.c +707 -0
- data/ext/asyncengine_ext/libuv/src/unix/idle.c +79 -0
- data/ext/asyncengine_ext/libuv/src/unix/internal.h +161 -0
- data/ext/asyncengine_ext/libuv/src/unix/kqueue.c +127 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/core.c +474 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/inotify.c +211 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/syscalls.c +230 -0
- data/ext/asyncengine_ext/libuv/src/unix/linux/syscalls.h +87 -0
- data/ext/asyncengine_ext/libuv/src/unix/loop.c +58 -0
- data/ext/asyncengine_ext/libuv/src/unix/netbsd.c +108 -0
- data/ext/asyncengine_ext/libuv/src/unix/openbsd.c +295 -0
- data/ext/asyncengine_ext/libuv/src/unix/pipe.c +266 -0
- data/ext/asyncengine_ext/libuv/src/unix/prepare.c +79 -0
- data/ext/asyncengine_ext/libuv/src/unix/process.c +369 -0
- data/ext/asyncengine_ext/libuv/src/unix/stream.c +1033 -0
- data/ext/asyncengine_ext/libuv/src/unix/sunos.c +466 -0
- data/ext/asyncengine_ext/libuv/src/unix/tcp.c +327 -0
- data/ext/asyncengine_ext/libuv/src/unix/thread.c +154 -0
- data/ext/asyncengine_ext/libuv/src/unix/timer.c +127 -0
- data/ext/asyncengine_ext/libuv/src/unix/tty.c +146 -0
- data/ext/asyncengine_ext/libuv/src/unix/udp.c +670 -0
- data/ext/asyncengine_ext/libuv/src/unix/uv-eio.c +124 -0
- data/ext/asyncengine_ext/libuv/src/unix/uv-eio.h +13 -0
- data/ext/asyncengine_ext/libuv/src/uv-common.c +354 -0
- data/ext/asyncengine_ext/libuv/src/uv-common.h +87 -0
- data/ext/asyncengine_ext/libuv/src/win/async.c +127 -0
- data/ext/asyncengine_ext/libuv/src/win/cares.c +290 -0
- data/ext/asyncengine_ext/libuv/src/win/core.c +270 -0
- data/ext/asyncengine_ext/libuv/src/win/dl.c +82 -0
- data/ext/asyncengine_ext/libuv/src/win/error.c +132 -0
- data/ext/asyncengine_ext/libuv/src/win/fs-event.c +514 -0
- data/ext/asyncengine_ext/libuv/src/win/fs.c +1576 -0
- data/ext/asyncengine_ext/libuv/src/win/getaddrinfo.c +372 -0
- data/ext/asyncengine_ext/libuv/src/win/handle.c +225 -0
- data/ext/asyncengine_ext/libuv/src/win/internal.h +352 -0
- data/ext/asyncengine_ext/libuv/src/win/loop-watcher.c +131 -0
- data/ext/asyncengine_ext/libuv/src/win/pipe.c +1661 -0
- data/ext/asyncengine_ext/libuv/src/win/process.c +1140 -0
- data/ext/asyncengine_ext/libuv/src/win/req.c +174 -0
- data/ext/asyncengine_ext/libuv/src/win/stream.c +201 -0
- data/ext/asyncengine_ext/libuv/src/win/tcp.c +1282 -0
- data/ext/asyncengine_ext/libuv/src/win/thread.c +332 -0
- data/ext/asyncengine_ext/libuv/src/win/threadpool.c +73 -0
- data/ext/asyncengine_ext/libuv/src/win/timer.c +276 -0
- data/ext/asyncengine_ext/libuv/src/win/tty.c +1795 -0
- data/ext/asyncengine_ext/libuv/src/win/udp.c +709 -0
- data/ext/asyncengine_ext/libuv/src/win/util.c +719 -0
- data/ext/asyncengine_ext/libuv/src/win/winapi.c +117 -0
- data/ext/asyncengine_ext/libuv/src/win/winapi.h +4419 -0
- data/ext/asyncengine_ext/libuv/src/win/winsock.c +470 -0
- data/ext/asyncengine_ext/libuv/src/win/winsock.h +138 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-ares.c +118 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-getaddrinfo.c +94 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-list.h +105 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-ping-pongs.c +213 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-pound.c +324 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-pump.c +462 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-sizes.c +40 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-spawn.c +156 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-tcp-write-batch.c +140 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-thread.c +64 -0
- data/ext/asyncengine_ext/libuv/test/benchmark-udp-packet-storm.c +247 -0
- data/ext/asyncengine_ext/libuv/test/blackhole-server.c +118 -0
- data/ext/asyncengine_ext/libuv/test/dns-server.c +321 -0
- data/ext/asyncengine_ext/libuv/test/echo-server.c +370 -0
- data/ext/asyncengine_ext/libuv/test/fixtures/empty_file +0 -0
- data/ext/asyncengine_ext/libuv/test/fixtures/load_error.node +1 -0
- data/ext/asyncengine_ext/libuv/test/run-benchmarks.c +64 -0
- data/ext/asyncengine_ext/libuv/test/run-tests.c +108 -0
- data/ext/asyncengine_ext/libuv/test/runner-unix.c +315 -0
- data/ext/asyncengine_ext/libuv/test/runner-unix.h +36 -0
- data/ext/asyncengine_ext/libuv/test/runner-win.c +343 -0
- data/ext/asyncengine_ext/libuv/test/runner-win.h +42 -0
- data/ext/asyncengine_ext/libuv/test/runner.c +317 -0
- data/ext/asyncengine_ext/libuv/test/runner.h +159 -0
- data/ext/asyncengine_ext/libuv/test/task.h +117 -0
- data/ext/asyncengine_ext/libuv/test/test-async.c +216 -0
- data/ext/asyncengine_ext/libuv/test/test-callback-stack.c +203 -0
- data/ext/asyncengine_ext/libuv/test/test-connection-fail.c +148 -0
- data/ext/asyncengine_ext/libuv/test/test-counters-init.c +216 -0
- data/ext/asyncengine_ext/libuv/test/test-cwd-and-chdir.c +64 -0
- data/ext/asyncengine_ext/libuv/test/test-delayed-accept.c +197 -0
- data/ext/asyncengine_ext/libuv/test/test-dlerror.c +49 -0
- data/ext/asyncengine_ext/libuv/test/test-eio-overflow.c +90 -0
- data/ext/asyncengine_ext/libuv/test/test-error.c +59 -0
- data/ext/asyncengine_ext/libuv/test/test-fail-always.c +29 -0
- data/ext/asyncengine_ext/libuv/test/test-fs-event.c +442 -0
- data/ext/asyncengine_ext/libuv/test/test-fs.c +1731 -0
- data/ext/asyncengine_ext/libuv/test/test-get-currentexe.c +63 -0
- data/ext/asyncengine_ext/libuv/test/test-get-loadavg.c +36 -0
- data/ext/asyncengine_ext/libuv/test/test-get-memory.c +38 -0
- data/ext/asyncengine_ext/libuv/test/test-getaddrinfo.c +122 -0
- data/ext/asyncengine_ext/libuv/test/test-gethostbyname.c +189 -0
- data/ext/asyncengine_ext/libuv/test/test-getsockname.c +342 -0
- data/ext/asyncengine_ext/libuv/test/test-hrtime.c +51 -0
- data/ext/asyncengine_ext/libuv/test/test-idle.c +81 -0
- data/ext/asyncengine_ext/libuv/test/test-ipc-send-recv.c +209 -0
- data/ext/asyncengine_ext/libuv/test/test-ipc.c +614 -0
- data/ext/asyncengine_ext/libuv/test/test-list.h +371 -0
- data/ext/asyncengine_ext/libuv/test/test-loop-handles.c +359 -0
- data/ext/asyncengine_ext/libuv/test/test-multiple-listen.c +102 -0
- data/ext/asyncengine_ext/libuv/test/test-mutexes.c +63 -0
- data/ext/asyncengine_ext/libuv/test/test-pass-always.c +28 -0
- data/ext/asyncengine_ext/libuv/test/test-ping-pong.c +253 -0
- data/ext/asyncengine_ext/libuv/test/test-pipe-bind-error.c +140 -0
- data/ext/asyncengine_ext/libuv/test/test-pipe-connect-error.c +96 -0
- data/ext/asyncengine_ext/libuv/test/test-platform-output.c +87 -0
- data/ext/asyncengine_ext/libuv/test/test-process-title.c +42 -0
- data/ext/asyncengine_ext/libuv/test/test-ref.c +322 -0
- data/ext/asyncengine_ext/libuv/test/test-run-once.c +44 -0
- data/ext/asyncengine_ext/libuv/test/test-shutdown-close.c +103 -0
- data/ext/asyncengine_ext/libuv/test/test-shutdown-eof.c +183 -0
- data/ext/asyncengine_ext/libuv/test/test-spawn.c +499 -0
- data/ext/asyncengine_ext/libuv/test/test-stdio-over-pipes.c +256 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-bind-error.c +191 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-bind6-error.c +154 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-close.c +129 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-connect-error.c +70 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-connect6-error.c +68 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-flags.c +51 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-write-error.c +168 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-write-to-half-open-connection.c +135 -0
- data/ext/asyncengine_ext/libuv/test/test-tcp-writealot.c +195 -0
- data/ext/asyncengine_ext/libuv/test/test-thread.c +183 -0
- data/ext/asyncengine_ext/libuv/test/test-threadpool.c +57 -0
- data/ext/asyncengine_ext/libuv/test/test-timer-again.c +141 -0
- data/ext/asyncengine_ext/libuv/test/test-timer.c +130 -0
- data/ext/asyncengine_ext/libuv/test/test-tty.c +110 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-dgram-too-big.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-ipv6.c +156 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-multicast-join.c +139 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-multicast-ttl.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-options.c +86 -0
- data/ext/asyncengine_ext/libuv/test/test-udp-send-and-recv.c +208 -0
- data/ext/asyncengine_ext/libuv/test/test-util.c +97 -0
- data/ext/asyncengine_ext/libuv/uv.gyp +435 -0
- data/ext/asyncengine_ext/libuv/vcbuild.bat +105 -0
- data/lib/asyncengine/version.rb +3 -0
- data/lib/asyncengine.rb +41 -0
- metadata +384 -0
@@ -0,0 +1,719 @@
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
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
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
7
|
+
* sell 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
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
19
|
+
* IN THE SOFTWARE.
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <assert.h>
|
23
|
+
#include <direct.h>
|
24
|
+
#include <malloc.h>
|
25
|
+
#include <stdio.h>
|
26
|
+
#include <string.h>
|
27
|
+
#include <time.h>
|
28
|
+
#include <wchar.h>
|
29
|
+
|
30
|
+
#include "uv.h"
|
31
|
+
#include "internal.h"
|
32
|
+
#include "tlhelp32.h"
|
33
|
+
#include "psapi.h"
|
34
|
+
#include "iphlpapi.h"
|
35
|
+
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Max title length; the only thing MSDN tells us about the maximum length
|
39
|
+
* of the console title is that it is smaller than 64K. However in practice
|
40
|
+
* it is much smaller, and there is no way to figure out what the exact length
|
41
|
+
* of the title is or can be, at least not on XP. To make it even more
|
42
|
+
* annoying, GetConsoleTitle failes when the buffer to be read into is bigger
|
43
|
+
* than the actual maximum length. So we make a conservative guess here;
|
44
|
+
* just don't put the novel you're writing in the title, unless the plot
|
45
|
+
* survives truncation.
|
46
|
+
*/
|
47
|
+
#define MAX_TITLE_LENGTH 8192
|
48
|
+
|
49
|
+
|
50
|
+
static char *process_title;
|
51
|
+
static uv_once_t uv_process_title_init_guard_ = UV_ONCE_INIT;
|
52
|
+
static CRITICAL_SECTION process_title_lock;
|
53
|
+
|
54
|
+
int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
|
55
|
+
char* utf8Buffer, size_t utf8Size) {
|
56
|
+
return WideCharToMultiByte(CP_UTF8,
|
57
|
+
0,
|
58
|
+
utf16Buffer,
|
59
|
+
utf16Size,
|
60
|
+
utf8Buffer,
|
61
|
+
utf8Size,
|
62
|
+
NULL,
|
63
|
+
NULL);
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer,
|
68
|
+
size_t utf16Size) {
|
69
|
+
return MultiByteToWideChar(CP_UTF8,
|
70
|
+
0,
|
71
|
+
utf8Buffer,
|
72
|
+
-1,
|
73
|
+
utf16Buffer,
|
74
|
+
utf16Size);
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
int uv_exepath(char* buffer, size_t* size) {
|
79
|
+
int retVal;
|
80
|
+
size_t utf16Size;
|
81
|
+
wchar_t* utf16Buffer;
|
82
|
+
|
83
|
+
if (!buffer || !size) {
|
84
|
+
return -1;
|
85
|
+
}
|
86
|
+
|
87
|
+
utf16Buffer = (wchar_t*)malloc(sizeof(wchar_t) * *size);
|
88
|
+
if (!utf16Buffer) {
|
89
|
+
retVal = -1;
|
90
|
+
goto done;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* Get the path as UTF-16 */
|
94
|
+
utf16Size = GetModuleFileNameW(NULL, utf16Buffer, *size - 1);
|
95
|
+
if (utf16Size <= 0) {
|
96
|
+
/* uv__set_sys_error(loop, GetLastError()); */
|
97
|
+
retVal = -1;
|
98
|
+
goto done;
|
99
|
+
}
|
100
|
+
|
101
|
+
utf16Buffer[utf16Size] = L'\0';
|
102
|
+
|
103
|
+
/* Convert to UTF-8 */
|
104
|
+
*size = uv_utf16_to_utf8(utf16Buffer, utf16Size, buffer, *size);
|
105
|
+
if (!*size) {
|
106
|
+
/* uv__set_sys_error(loop, GetLastError()); */
|
107
|
+
retVal = -1;
|
108
|
+
goto done;
|
109
|
+
}
|
110
|
+
|
111
|
+
buffer[*size] = '\0';
|
112
|
+
retVal = 0;
|
113
|
+
|
114
|
+
done:
|
115
|
+
if (utf16Buffer) {
|
116
|
+
free(utf16Buffer);
|
117
|
+
}
|
118
|
+
|
119
|
+
return retVal;
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
uv_err_t uv_cwd(char* buffer, size_t size) {
|
124
|
+
uv_err_t err;
|
125
|
+
size_t utf8Size;
|
126
|
+
wchar_t* utf16Buffer = NULL;
|
127
|
+
|
128
|
+
if (!buffer || !size) {
|
129
|
+
err.code = UV_EINVAL;
|
130
|
+
goto done;
|
131
|
+
}
|
132
|
+
|
133
|
+
utf16Buffer = (wchar_t*)malloc(sizeof(wchar_t) * size);
|
134
|
+
if (!utf16Buffer) {
|
135
|
+
err.code = UV_ENOMEM;
|
136
|
+
goto done;
|
137
|
+
}
|
138
|
+
|
139
|
+
if (!_wgetcwd(utf16Buffer, size - 1)) {
|
140
|
+
err = uv__new_sys_error(_doserrno);
|
141
|
+
goto done;
|
142
|
+
}
|
143
|
+
|
144
|
+
utf16Buffer[size - 1] = L'\0';
|
145
|
+
|
146
|
+
/* Convert to UTF-8 */
|
147
|
+
utf8Size = uv_utf16_to_utf8(utf16Buffer, -1, buffer, size);
|
148
|
+
if (utf8Size == 0) {
|
149
|
+
err = uv__new_sys_error(GetLastError());
|
150
|
+
goto done;
|
151
|
+
}
|
152
|
+
|
153
|
+
buffer[utf8Size] = '\0';
|
154
|
+
err = uv_ok_;
|
155
|
+
|
156
|
+
done:
|
157
|
+
if (utf16Buffer) {
|
158
|
+
free(utf16Buffer);
|
159
|
+
}
|
160
|
+
|
161
|
+
return err;
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
uv_err_t uv_chdir(const char* dir) {
|
166
|
+
uv_err_t err;
|
167
|
+
wchar_t* utf16Buffer = NULL;
|
168
|
+
size_t utf16Size;
|
169
|
+
|
170
|
+
if (!dir) {
|
171
|
+
err.code = UV_EINVAL;
|
172
|
+
goto done;
|
173
|
+
}
|
174
|
+
|
175
|
+
utf16Size = uv_utf8_to_utf16(dir, NULL, 0);
|
176
|
+
if (!utf16Size) {
|
177
|
+
err = uv__new_sys_error(GetLastError());
|
178
|
+
goto done;
|
179
|
+
}
|
180
|
+
|
181
|
+
utf16Buffer = (wchar_t*)malloc(sizeof(wchar_t) * utf16Size);
|
182
|
+
if (!utf16Buffer) {
|
183
|
+
err.code = UV_ENOMEM;
|
184
|
+
goto done;
|
185
|
+
}
|
186
|
+
|
187
|
+
if (!uv_utf8_to_utf16(dir, utf16Buffer, utf16Size)) {
|
188
|
+
err = uv__new_sys_error(GetLastError());
|
189
|
+
goto done;
|
190
|
+
}
|
191
|
+
|
192
|
+
if (_wchdir(utf16Buffer) == -1) {
|
193
|
+
err = uv__new_sys_error(_doserrno);
|
194
|
+
goto done;
|
195
|
+
}
|
196
|
+
|
197
|
+
err = uv_ok_;
|
198
|
+
|
199
|
+
done:
|
200
|
+
if (utf16Buffer) {
|
201
|
+
free(utf16Buffer);
|
202
|
+
}
|
203
|
+
|
204
|
+
return err;
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
void uv_loadavg(double avg[3]) {
|
209
|
+
/* Can't be implemented */
|
210
|
+
avg[0] = avg[1] = avg[2] = 0;
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
uint64_t uv_get_free_memory(void) {
|
215
|
+
MEMORYSTATUSEX memory_status;
|
216
|
+
memory_status.dwLength = sizeof(memory_status);
|
217
|
+
|
218
|
+
if(!GlobalMemoryStatusEx(&memory_status))
|
219
|
+
{
|
220
|
+
return -1;
|
221
|
+
}
|
222
|
+
|
223
|
+
return (uint64_t)memory_status.ullAvailPhys;
|
224
|
+
}
|
225
|
+
|
226
|
+
|
227
|
+
uint64_t uv_get_total_memory(void) {
|
228
|
+
MEMORYSTATUSEX memory_status;
|
229
|
+
memory_status.dwLength = sizeof(memory_status);
|
230
|
+
|
231
|
+
if(!GlobalMemoryStatusEx(&memory_status))
|
232
|
+
{
|
233
|
+
return -1;
|
234
|
+
}
|
235
|
+
|
236
|
+
return (uint64_t)memory_status.ullTotalPhys;
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
int uv_parent_pid() {
|
241
|
+
int parent_pid = -1;
|
242
|
+
HANDLE handle;
|
243
|
+
PROCESSENTRY32 pe;
|
244
|
+
int current_pid = GetCurrentProcessId();
|
245
|
+
|
246
|
+
pe.dwSize = sizeof(PROCESSENTRY32);
|
247
|
+
handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
248
|
+
|
249
|
+
if (Process32First(handle, &pe)) {
|
250
|
+
do {
|
251
|
+
if (pe.th32ProcessID == current_pid) {
|
252
|
+
parent_pid = pe.th32ParentProcessID;
|
253
|
+
break;
|
254
|
+
}
|
255
|
+
} while( Process32Next(handle, &pe));
|
256
|
+
}
|
257
|
+
|
258
|
+
CloseHandle(handle);
|
259
|
+
return parent_pid;
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
char** uv_setup_args(int argc, char** argv) {
|
264
|
+
return argv;
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
static void uv_process_title_init(void) {
|
269
|
+
InitializeCriticalSection(&process_title_lock);
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
uv_err_t uv_set_process_title(const char* title) {
|
274
|
+
uv_err_t err;
|
275
|
+
int length;
|
276
|
+
wchar_t* title_w = NULL;
|
277
|
+
|
278
|
+
uv_once(&uv_process_title_init_guard_, uv_process_title_init);
|
279
|
+
|
280
|
+
/* Find out how big the buffer for the wide-char title must be */
|
281
|
+
length = uv_utf8_to_utf16(title, NULL, 0);
|
282
|
+
if (!length) {
|
283
|
+
err = uv__new_sys_error(GetLastError());
|
284
|
+
goto done;
|
285
|
+
}
|
286
|
+
|
287
|
+
/* Convert to wide-char string */
|
288
|
+
title_w = (wchar_t*)malloc(sizeof(wchar_t) * length);
|
289
|
+
if (!title_w) {
|
290
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
291
|
+
}
|
292
|
+
|
293
|
+
length = uv_utf8_to_utf16(title, title_w, length);
|
294
|
+
if (!length) {
|
295
|
+
err = uv__new_sys_error(GetLastError());
|
296
|
+
goto done;
|
297
|
+
};
|
298
|
+
|
299
|
+
/* If the title must be truncated insert a \0 terminator there */
|
300
|
+
if (length > MAX_TITLE_LENGTH) {
|
301
|
+
title_w[MAX_TITLE_LENGTH - 1] = L'\0';
|
302
|
+
}
|
303
|
+
|
304
|
+
if (!SetConsoleTitleW(title_w)) {
|
305
|
+
err = uv__new_sys_error(GetLastError());
|
306
|
+
goto done;
|
307
|
+
}
|
308
|
+
|
309
|
+
EnterCriticalSection(&process_title_lock);
|
310
|
+
free(process_title);
|
311
|
+
process_title = strdup(title);
|
312
|
+
LeaveCriticalSection(&process_title_lock);
|
313
|
+
|
314
|
+
err = uv_ok_;
|
315
|
+
|
316
|
+
done:
|
317
|
+
free(title_w);
|
318
|
+
return err;
|
319
|
+
}
|
320
|
+
|
321
|
+
|
322
|
+
static int uv__get_process_title() {
|
323
|
+
wchar_t title_w[MAX_TITLE_LENGTH];
|
324
|
+
int length;
|
325
|
+
|
326
|
+
if (!GetConsoleTitleW(title_w, sizeof(title_w) / sizeof(WCHAR))) {
|
327
|
+
return -1;
|
328
|
+
}
|
329
|
+
|
330
|
+
/* Find out what the size of the buffer is that we need */
|
331
|
+
length = uv_utf16_to_utf8(title_w, -1, NULL, 0);
|
332
|
+
if (!length) {
|
333
|
+
return -1;
|
334
|
+
}
|
335
|
+
|
336
|
+
assert(!process_title);
|
337
|
+
process_title = (char*)malloc(length);
|
338
|
+
if (!process_title) {
|
339
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
340
|
+
}
|
341
|
+
|
342
|
+
/* Do utf16 -> utf8 conversion here */
|
343
|
+
if (!uv_utf16_to_utf8(title_w, -1, process_title, length)) {
|
344
|
+
free(process_title);
|
345
|
+
return -1;
|
346
|
+
}
|
347
|
+
|
348
|
+
return 0;
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
uv_err_t uv_get_process_title(char* buffer, size_t size) {
|
353
|
+
uv_once(&uv_process_title_init_guard_, uv_process_title_init);
|
354
|
+
|
355
|
+
EnterCriticalSection(&process_title_lock);
|
356
|
+
/*
|
357
|
+
* If the process_title was never read before nor explicitly set,
|
358
|
+
* we must query it with getConsoleTitleW
|
359
|
+
*/
|
360
|
+
if (!process_title && uv__get_process_title() == -1) {
|
361
|
+
return uv__new_sys_error(GetLastError());
|
362
|
+
}
|
363
|
+
|
364
|
+
assert(process_title);
|
365
|
+
strncpy(buffer, process_title, size);
|
366
|
+
LeaveCriticalSection(&process_title_lock);
|
367
|
+
|
368
|
+
return uv_ok_;
|
369
|
+
}
|
370
|
+
|
371
|
+
|
372
|
+
uv_err_t uv_resident_set_memory(size_t* rss) {
|
373
|
+
HANDLE current_process;
|
374
|
+
PROCESS_MEMORY_COUNTERS pmc;
|
375
|
+
|
376
|
+
current_process = GetCurrentProcess();
|
377
|
+
|
378
|
+
if (!GetProcessMemoryInfo(current_process, &pmc, sizeof(pmc))) {
|
379
|
+
return uv__new_sys_error(GetLastError());
|
380
|
+
}
|
381
|
+
|
382
|
+
*rss = pmc.WorkingSetSize;
|
383
|
+
|
384
|
+
return uv_ok_;
|
385
|
+
}
|
386
|
+
|
387
|
+
|
388
|
+
uv_err_t uv_uptime(double* uptime) {
|
389
|
+
BYTE stack_buffer[4096];
|
390
|
+
BYTE* malloced_buffer = NULL;
|
391
|
+
BYTE* buffer = (BYTE*) stack_buffer;
|
392
|
+
size_t buffer_size = sizeof(stack_buffer);
|
393
|
+
DWORD data_size;
|
394
|
+
|
395
|
+
PERF_DATA_BLOCK* data_block;
|
396
|
+
PERF_OBJECT_TYPE* object_type;
|
397
|
+
PERF_COUNTER_DEFINITION* counter_definition;
|
398
|
+
|
399
|
+
DWORD i;
|
400
|
+
|
401
|
+
for (;;) {
|
402
|
+
LONG result;
|
403
|
+
|
404
|
+
data_size = (DWORD) buffer_size;
|
405
|
+
result = RegQueryValueExW(HKEY_PERFORMANCE_DATA,
|
406
|
+
L"2",
|
407
|
+
NULL,
|
408
|
+
NULL,
|
409
|
+
buffer,
|
410
|
+
&data_size);
|
411
|
+
if (result == ERROR_SUCCESS) {
|
412
|
+
break;
|
413
|
+
} else if (result != ERROR_MORE_DATA) {
|
414
|
+
*uptime = 0;
|
415
|
+
return uv__new_sys_error(result);
|
416
|
+
}
|
417
|
+
|
418
|
+
free(malloced_buffer);
|
419
|
+
|
420
|
+
buffer_size *= 2;
|
421
|
+
/* Don't let the buffer grow infinitely. */
|
422
|
+
if (buffer_size > 1 << 20) {
|
423
|
+
goto internalError;
|
424
|
+
}
|
425
|
+
|
426
|
+
buffer = malloced_buffer = (BYTE*) malloc(buffer_size);
|
427
|
+
if (malloced_buffer == NULL) {
|
428
|
+
*uptime = 0;
|
429
|
+
return uv__new_artificial_error(UV_ENOMEM);
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
if (data_size < sizeof(*data_block))
|
434
|
+
goto internalError;
|
435
|
+
|
436
|
+
data_block = (PERF_DATA_BLOCK*) buffer;
|
437
|
+
|
438
|
+
if (wmemcmp(data_block->Signature, L"PERF", 4) != 0)
|
439
|
+
goto internalError;
|
440
|
+
|
441
|
+
if (data_size < data_block->HeaderLength + sizeof(*object_type))
|
442
|
+
goto internalError;
|
443
|
+
|
444
|
+
object_type = (PERF_OBJECT_TYPE*) (buffer + data_block->HeaderLength);
|
445
|
+
|
446
|
+
if (object_type->NumInstances != PERF_NO_INSTANCES)
|
447
|
+
goto internalError;
|
448
|
+
|
449
|
+
counter_definition = (PERF_COUNTER_DEFINITION*) (buffer +
|
450
|
+
data_block->HeaderLength + object_type->HeaderLength);
|
451
|
+
for (i = 0; i < object_type->NumCounters; i++) {
|
452
|
+
if ((BYTE*) counter_definition + sizeof(*counter_definition) >
|
453
|
+
buffer + data_size) {
|
454
|
+
break;
|
455
|
+
}
|
456
|
+
|
457
|
+
if (counter_definition->CounterNameTitleIndex == 674 &&
|
458
|
+
counter_definition->CounterSize == sizeof(uint64_t)) {
|
459
|
+
if (counter_definition->CounterOffset + sizeof(uint64_t) > data_size ||
|
460
|
+
!(counter_definition->CounterType & PERF_OBJECT_TIMER)) {
|
461
|
+
goto internalError;
|
462
|
+
} else {
|
463
|
+
BYTE* address = (BYTE*) object_type + object_type->DefinitionLength +
|
464
|
+
counter_definition->CounterOffset;
|
465
|
+
uint64_t value = *((uint64_t*) address);
|
466
|
+
*uptime = (double) (object_type->PerfTime.QuadPart - value) /
|
467
|
+
(double) object_type->PerfFreq.QuadPart;
|
468
|
+
free(malloced_buffer);
|
469
|
+
return uv_ok_;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
|
473
|
+
counter_definition = (PERF_COUNTER_DEFINITION*)
|
474
|
+
((BYTE*) counter_definition + counter_definition->ByteLength);
|
475
|
+
}
|
476
|
+
|
477
|
+
/* If we get here, the uptime value was not found. */
|
478
|
+
free(malloced_buffer);
|
479
|
+
*uptime = 0;
|
480
|
+
return uv__new_artificial_error(UV_ENOSYS);
|
481
|
+
|
482
|
+
internalError:
|
483
|
+
free(malloced_buffer);
|
484
|
+
*uptime = 0;
|
485
|
+
return uv__new_artificial_error(UV_EIO);
|
486
|
+
}
|
487
|
+
|
488
|
+
|
489
|
+
uv_err_t uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
490
|
+
uv_err_t err;
|
491
|
+
char key[128];
|
492
|
+
HKEY processor_key = NULL;
|
493
|
+
DWORD cpu_speed = 0;
|
494
|
+
DWORD cpu_speed_length = sizeof(cpu_speed);
|
495
|
+
char cpu_brand[256];
|
496
|
+
DWORD cpu_brand_length = sizeof(cpu_brand);
|
497
|
+
SYSTEM_INFO system_info;
|
498
|
+
uv_cpu_info_t* cpu_info;
|
499
|
+
unsigned int i;
|
500
|
+
|
501
|
+
GetSystemInfo(&system_info);
|
502
|
+
|
503
|
+
*cpu_infos = (uv_cpu_info_t*)malloc(system_info.dwNumberOfProcessors *
|
504
|
+
sizeof(uv_cpu_info_t));
|
505
|
+
if (!(*cpu_infos)) {
|
506
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
507
|
+
}
|
508
|
+
|
509
|
+
*count = 0;
|
510
|
+
|
511
|
+
for (i = 0; i < system_info.dwNumberOfProcessors; i++) {
|
512
|
+
_snprintf(key, sizeof(key), "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\%d", i);
|
513
|
+
|
514
|
+
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_QUERY_VALUE,
|
515
|
+
&processor_key) != ERROR_SUCCESS) {
|
516
|
+
if (i == 0) {
|
517
|
+
err = uv__new_sys_error(GetLastError());
|
518
|
+
goto done;
|
519
|
+
}
|
520
|
+
|
521
|
+
continue;
|
522
|
+
}
|
523
|
+
|
524
|
+
if (RegQueryValueEx(processor_key, "~MHz", NULL, NULL,
|
525
|
+
(LPBYTE)&cpu_speed, &cpu_speed_length)
|
526
|
+
!= ERROR_SUCCESS) {
|
527
|
+
err = uv__new_sys_error(GetLastError());
|
528
|
+
goto done;
|
529
|
+
}
|
530
|
+
|
531
|
+
if (RegQueryValueEx(processor_key, "ProcessorNameString", NULL, NULL,
|
532
|
+
(LPBYTE)&cpu_brand, &cpu_brand_length)
|
533
|
+
!= ERROR_SUCCESS) {
|
534
|
+
err = uv__new_sys_error(GetLastError());
|
535
|
+
goto done;
|
536
|
+
}
|
537
|
+
|
538
|
+
RegCloseKey(processor_key);
|
539
|
+
processor_key = NULL;
|
540
|
+
|
541
|
+
cpu_info = &(*cpu_infos)[i];
|
542
|
+
|
543
|
+
/* $TODO: find times on windows */
|
544
|
+
cpu_info->cpu_times.user = 0;
|
545
|
+
cpu_info->cpu_times.nice = 0;
|
546
|
+
cpu_info->cpu_times.sys = 0;
|
547
|
+
cpu_info->cpu_times.idle = 0;
|
548
|
+
cpu_info->cpu_times.irq = 0;
|
549
|
+
|
550
|
+
cpu_info->model = strdup(cpu_brand);
|
551
|
+
cpu_info->speed = cpu_speed;
|
552
|
+
|
553
|
+
(*count)++;
|
554
|
+
}
|
555
|
+
|
556
|
+
err = uv_ok_;
|
557
|
+
|
558
|
+
done:
|
559
|
+
if (processor_key) {
|
560
|
+
RegCloseKey(processor_key);
|
561
|
+
}
|
562
|
+
|
563
|
+
if (err.code != UV_OK) {
|
564
|
+
free(*cpu_infos);
|
565
|
+
*cpu_infos = NULL;
|
566
|
+
*count = 0;
|
567
|
+
}
|
568
|
+
|
569
|
+
return err;
|
570
|
+
}
|
571
|
+
|
572
|
+
|
573
|
+
void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
|
574
|
+
int i;
|
575
|
+
|
576
|
+
for (i = 0; i < count; i++) {
|
577
|
+
free(cpu_infos[i].model);
|
578
|
+
}
|
579
|
+
|
580
|
+
free(cpu_infos);
|
581
|
+
}
|
582
|
+
|
583
|
+
|
584
|
+
uv_err_t uv_interface_addresses(uv_interface_address_t** addresses,
|
585
|
+
int* count) {
|
586
|
+
unsigned long size = 0;
|
587
|
+
IP_ADAPTER_ADDRESSES* adapter_addresses;
|
588
|
+
IP_ADAPTER_ADDRESSES* adapter_address;
|
589
|
+
uv_interface_address_t* address;
|
590
|
+
struct sockaddr* sock_addr;
|
591
|
+
int length;
|
592
|
+
char* name;
|
593
|
+
/* Use IP_ADAPTER_UNICAST_ADDRESS_XP to retain backwards compatibility */
|
594
|
+
/* with Windows XP */
|
595
|
+
IP_ADAPTER_UNICAST_ADDRESS_XP* unicast_address;
|
596
|
+
|
597
|
+
if (GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size)
|
598
|
+
!= ERROR_BUFFER_OVERFLOW) {
|
599
|
+
return uv__new_sys_error(GetLastError());
|
600
|
+
}
|
601
|
+
|
602
|
+
adapter_addresses = (IP_ADAPTER_ADDRESSES*)malloc(size);
|
603
|
+
if (!adapter_addresses) {
|
604
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
605
|
+
}
|
606
|
+
|
607
|
+
if (GetAdaptersAddresses(AF_UNSPEC, 0, NULL, adapter_addresses, &size)
|
608
|
+
!= ERROR_SUCCESS) {
|
609
|
+
return uv__new_sys_error(GetLastError());
|
610
|
+
}
|
611
|
+
|
612
|
+
/* Count the number of interfaces */
|
613
|
+
*count = 0;
|
614
|
+
|
615
|
+
for (adapter_address = adapter_addresses;
|
616
|
+
adapter_address != NULL;
|
617
|
+
adapter_address = adapter_address->Next) {
|
618
|
+
unicast_address = (IP_ADAPTER_UNICAST_ADDRESS_XP*)
|
619
|
+
adapter_address->FirstUnicastAddress;
|
620
|
+
while (unicast_address) {
|
621
|
+
(*count)++;
|
622
|
+
unicast_address = unicast_address->Next;
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
*addresses = (uv_interface_address_t*)
|
627
|
+
malloc(*count * sizeof(uv_interface_address_t));
|
628
|
+
if (!(*addresses)) {
|
629
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
630
|
+
}
|
631
|
+
|
632
|
+
address = *addresses;
|
633
|
+
|
634
|
+
for (adapter_address = adapter_addresses;
|
635
|
+
adapter_address != NULL;
|
636
|
+
adapter_address = adapter_address->Next) {
|
637
|
+
name = NULL;
|
638
|
+
unicast_address = (IP_ADAPTER_UNICAST_ADDRESS_XP*)
|
639
|
+
adapter_address->FirstUnicastAddress;
|
640
|
+
|
641
|
+
while (unicast_address) {
|
642
|
+
sock_addr = unicast_address->Address.lpSockaddr;
|
643
|
+
if (sock_addr->sa_family == AF_INET6) {
|
644
|
+
address->address.address6 = *((struct sockaddr_in6 *)sock_addr);
|
645
|
+
} else {
|
646
|
+
address->address.address4 = *((struct sockaddr_in *)sock_addr);
|
647
|
+
}
|
648
|
+
|
649
|
+
address->is_internal =
|
650
|
+
adapter_address->IfType == IF_TYPE_SOFTWARE_LOOPBACK ? 1 : 0;
|
651
|
+
|
652
|
+
if (!name) {
|
653
|
+
/* Convert FriendlyName to utf8 */
|
654
|
+
length = uv_utf16_to_utf8(adapter_address->FriendlyName, -1, NULL, 0);
|
655
|
+
if (length) {
|
656
|
+
name = (char*)malloc(length);
|
657
|
+
if (!name) {
|
658
|
+
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
|
659
|
+
}
|
660
|
+
|
661
|
+
if (!uv_utf16_to_utf8(adapter_address->FriendlyName, -1, name,
|
662
|
+
length)) {
|
663
|
+
free(name);
|
664
|
+
name = NULL;
|
665
|
+
}
|
666
|
+
}
|
667
|
+
}
|
668
|
+
|
669
|
+
assert(name);
|
670
|
+
address->name = name;
|
671
|
+
|
672
|
+
unicast_address = unicast_address->Next;
|
673
|
+
address++;
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
free(adapter_addresses);
|
678
|
+
|
679
|
+
return uv_ok_;
|
680
|
+
}
|
681
|
+
|
682
|
+
|
683
|
+
void uv_free_interface_addresses(uv_interface_address_t* addresses,
|
684
|
+
int count) {
|
685
|
+
int i;
|
686
|
+
char* freed_name = NULL;
|
687
|
+
|
688
|
+
for (i = 0; i < count; i++) {
|
689
|
+
if (freed_name != addresses[i].name) {
|
690
|
+
freed_name = addresses[i].name;
|
691
|
+
free(freed_name);
|
692
|
+
}
|
693
|
+
}
|
694
|
+
|
695
|
+
free(addresses);
|
696
|
+
}
|
697
|
+
|
698
|
+
|
699
|
+
void uv_filetime_to_time_t(FILETIME* file_time, time_t* stat_time) {
|
700
|
+
FILETIME local_time;
|
701
|
+
SYSTEMTIME system_time;
|
702
|
+
struct tm time;
|
703
|
+
|
704
|
+
if ((file_time->dwLowDateTime || file_time->dwHighDateTime) &&
|
705
|
+
FileTimeToLocalFileTime(file_time, &local_time) &&
|
706
|
+
FileTimeToSystemTime(&local_time, &system_time)) {
|
707
|
+
time.tm_year = system_time.wYear - 1900;
|
708
|
+
time.tm_mon = system_time.wMonth - 1;
|
709
|
+
time.tm_mday = system_time.wDay;
|
710
|
+
time.tm_hour = system_time.wHour;
|
711
|
+
time.tm_min = system_time.wMinute;
|
712
|
+
time.tm_sec = system_time.wSecond;
|
713
|
+
time.tm_isdst = -1;
|
714
|
+
|
715
|
+
*stat_time = mktime(&time);
|
716
|
+
} else {
|
717
|
+
*stat_time = 0;
|
718
|
+
}
|
719
|
+
}
|