noderb 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/noderb_extension/libuv/AUTHORS +11 -1
- data/ext/noderb_extension/libuv/LICENSE +0 -8
- data/ext/noderb_extension/libuv/Makefile +5 -5
- data/ext/noderb_extension/libuv/README +11 -6
- data/ext/noderb_extension/libuv/common.gypi +158 -7
- data/ext/noderb_extension/libuv/config-unix.mk +34 -26
- data/ext/noderb_extension/libuv/gyp_uv +22 -4
- data/ext/noderb_extension/libuv/include/{eio.h → uv-private/eio.h} +2 -2
- data/ext/noderb_extension/libuv/include/{uv-unix.h → uv-private/uv-unix.h} +40 -0
- data/ext/noderb_extension/libuv/include/{uv-win.h → uv-private/uv-win.h} +96 -14
- data/ext/noderb_extension/libuv/include/uv.h +508 -83
- data/ext/noderb_extension/libuv/src/unix/cares.c +185 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +828 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_darwin.h +4 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_linux.h +5 -15
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.c +23 -2
- data/ext/noderb_extension/libuv/src/unix/error.c +102 -0
- data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_linux.h +26 -15
- data/ext/noderb_extension/libuv/src/unix/fs.c +562 -0
- data/ext/noderb_extension/libuv/src/unix/internal.h +75 -0
- data/ext/noderb_extension/libuv/src/unix/pipe.c +282 -0
- data/ext/noderb_extension/libuv/src/unix/process.c +287 -0
- data/ext/noderb_extension/libuv/src/unix/stream.c +727 -0
- data/ext/noderb_extension/libuv/src/unix/tcp.c +226 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +524 -0
- data/ext/noderb_extension/libuv/src/{uv-eio.c → unix/uv-eio.c} +48 -27
- data/ext/noderb_extension/libuv/src/{uv-eio.h → unix/uv-eio.h} +1 -1
- data/ext/noderb_extension/libuv/src/uv-common.c +24 -14
- data/ext/noderb_extension/libuv/src/uv-common.h +12 -7
- data/ext/noderb_extension/libuv/src/win/async.c +14 -16
- data/ext/noderb_extension/libuv/src/win/cares.c +64 -79
- data/ext/noderb_extension/libuv/src/win/core.c +105 -53
- data/ext/noderb_extension/libuv/src/win/error.c +23 -13
- data/ext/noderb_extension/libuv/src/win/fs.c +807 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +61 -41
- data/ext/noderb_extension/libuv/src/win/handle.c +56 -30
- data/ext/noderb_extension/libuv/src/win/internal.h +134 -95
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +21 -18
- data/ext/noderb_extension/libuv/src/win/pipe.c +313 -158
- data/ext/noderb_extension/libuv/src/win/process.c +117 -131
- data/ext/noderb_extension/libuv/src/win/req.c +55 -31
- data/ext/noderb_extension/libuv/src/win/stdio.c +5 -5
- data/ext/noderb_extension/libuv/src/win/stream.c +19 -14
- data/ext/noderb_extension/libuv/src/win/tcp.c +278 -336
- data/ext/noderb_extension/libuv/src/win/threadpool.c +73 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +44 -37
- data/ext/noderb_extension/libuv/src/win/udp.c +592 -0
- data/ext/noderb_extension/libuv/src/win/util.c +20 -6
- data/ext/noderb_extension/libuv/src/win/winapi.c +23 -6
- data/ext/noderb_extension/libuv/src/win/winapi.h +4206 -0
- data/ext/noderb_extension/libuv/src/win/winsock.c +270 -0
- data/ext/noderb_extension/libuv/src/win/winsock.h +134 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +10 -6
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +10 -7
- data/ext/noderb_extension/libuv/test/benchmark-list.h +21 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +11 -7
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +147 -58
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +29 -23
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +13 -10
- data/ext/noderb_extension/libuv/test/benchmark-udp-packet-storm.c +250 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +11 -6
- data/ext/noderb_extension/libuv/test/echo-server.c +30 -22
- data/ext/noderb_extension/libuv/test/test-async.c +3 -3
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +6 -6
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +6 -5
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +13 -13
- data/ext/noderb_extension/libuv/test/test-fs.c +715 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +11 -8
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +8 -9
- data/ext/noderb_extension/libuv/test/test-getsockname.c +142 -16
- data/ext/noderb_extension/libuv/test/test-idle.c +4 -3
- data/ext/noderb_extension/libuv/test/test-list.h +29 -2
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +9 -8
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +9 -9
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +18 -14
- data/ext/noderb_extension/libuv/test/test-ref.c +17 -16
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +5 -5
- data/ext/noderb_extension/libuv/test/test-spawn.c +17 -17
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +24 -18
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +19 -14
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +6 -5
- data/ext/noderb_extension/libuv/test/test-threadpool.c +59 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +15 -12
- data/ext/noderb_extension/libuv/test/test-timer.c +8 -8
- data/ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c +88 -0
- data/ext/noderb_extension/libuv/test/test-udp-ipv6.c +158 -0
- data/ext/noderb_extension/libuv/test/test-udp-send-and-recv.c +210 -0
- data/ext/noderb_extension/libuv/{all.gyp → uv.gyp} +75 -77
- data/ext/noderb_extension/libuv/vcbuild.bat +93 -0
- data/ext/noderb_extension/noderb.c +13 -0
- data/ext/noderb_extension/noderb_common.h +2 -1
- data/ext/noderb_extension/noderb_defer.c +54 -0
- data/ext/noderb_extension/noderb_defer.h +15 -0
- data/ext/noderb_extension/noderb_dns.c +1 -1
- data/ext/noderb_extension/noderb_fs.c +277 -0
- data/ext/noderb_extension/noderb_fs.h +27 -0
- data/ext/noderb_extension/noderb_process.c +5 -5
- data/ext/noderb_extension/noderb_tcp.c +10 -6
- data/ext/noderb_extension/noderb_timers.c +1 -1
- data/ext/noderb_extension/noderb_tools.c +42 -8
- data/ext/noderb_extension/noderb_tools.h +3 -1
- data/lib/noderb/defer.rb +25 -0
- data/lib/noderb/file.rb +119 -0
- data/lib/noderb/fs.rb +72 -0
- data/lib/noderb/version.rb +1 -1
- data/lib/noderb.rb +8 -0
- metadata +102 -266
- data/ext/noderb_extension/libuv/BSDmakefile +0 -2
- data/ext/noderb_extension/libuv/create-msvs-files.bat +0 -21
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +0 -482
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +0 -268
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +0 -140
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +0 -150
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +0 -504
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +0 -5194
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +0 -451
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +0 -593
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +0 -516
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +0 -1245
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +0 -24
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +0 -260
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +0 -601
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +0 -3036
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +0 -783
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +0 -6
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +0 -7
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +0 -222
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +0 -207
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +0 -9
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +0 -153
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +0 -74
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +0 -308
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +0 -39
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +0 -107
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +0 -944
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +0 -145
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +0 -66
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +0 -29
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +0 -1368
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +0 -52
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +0 -61
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +0 -100
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +0 -63
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +0 -55
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +0 -104
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +0 -85
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +0 -253
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +0 -231
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +0 -567
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +0 -172
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +0 -136
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +0 -76
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +0 -106
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +0 -45
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +0 -75
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +0 -65
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +0 -157
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +0 -130
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +0 -269
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +0 -324
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +0 -154
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +0 -175
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +0 -113
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +0 -139
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +0 -122
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +0 -93
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +0 -133
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +0 -84
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +0 -120
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +0 -126
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +0 -111
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +0 -80
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +0 -258
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +0 -278
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +0 -232
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +0 -132
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +0 -151
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +0 -357
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +0 -118
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +0 -114
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +0 -183
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +0 -134
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +0 -144
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +0 -128
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +0 -238
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +0 -179
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +0 -46
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +0 -43
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +0 -388
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +0 -161
- data/ext/noderb_extension/libuv/doc/iocp-links.html +0 -574
- data/ext/noderb_extension/libuv/src/uv-unix.c +0 -2421
- data/ext/noderb_extension/libuv/src/win/ntdll.h +0 -130
- /data/ext/noderb_extension/libuv/include/{ev.h → uv-private/ev.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{ngx-queue.h → uv-private/ngx-queue.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{tree.h → uv-private/tree.h} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-cygwin.c → unix/cygwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-darwin.c → unix/darwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/demo.c +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/ecb.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/libeio.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/xthread.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/README +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.guess +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.sub +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_darwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/depcomp +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev++.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_epoll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_kqueue.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_poll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_port.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_select.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_vars.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_win32.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_wrap.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/install-sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/libev.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ltmain.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/missing +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/mkinstalldirs +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-freebsd.c → unix/freebsd.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-linux.c → unix/linux.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-sunos.c → unix/sunos.c} +0 -0
@@ -0,0 +1,828 @@
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
2
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
3
|
+
* of this software and associated documentation files (the "Software"), to
|
4
|
+
* deal in the Software without restriction, including without limitation the
|
5
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
6
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
7
|
+
* furnished to do so, subject to the following conditions:
|
8
|
+
*
|
9
|
+
* The above copyright notice and this permission notice shall be included in
|
10
|
+
* all copies or substantial portions of the Software.
|
11
|
+
*
|
12
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
13
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
14
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
15
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
16
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
17
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
18
|
+
* IN THE SOFTWARE.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#ifndef _GNU_SOURCE
|
22
|
+
#define _GNU_SOURCE /* O_CLOEXEC, accept4(), etc. */
|
23
|
+
#endif
|
24
|
+
|
25
|
+
#include "uv.h"
|
26
|
+
#include "unix/internal.h"
|
27
|
+
|
28
|
+
#include <stddef.h> /* NULL */
|
29
|
+
#include <stdio.h> /* printf */
|
30
|
+
#include <stdlib.h>
|
31
|
+
#include <string.h> /* strerror */
|
32
|
+
#include <errno.h>
|
33
|
+
#include <assert.h>
|
34
|
+
#include <unistd.h>
|
35
|
+
#include <sys/types.h>
|
36
|
+
#include <sys/stat.h>
|
37
|
+
#include <fcntl.h>
|
38
|
+
#include <sys/socket.h>
|
39
|
+
#include <sys/un.h>
|
40
|
+
#include <netinet/in.h>
|
41
|
+
#include <arpa/inet.h>
|
42
|
+
#include <limits.h> /* PATH_MAX */
|
43
|
+
#include <sys/uio.h> /* writev */
|
44
|
+
|
45
|
+
#if defined(__linux__)
|
46
|
+
|
47
|
+
#include <linux/version.h>
|
48
|
+
#include <features.h>
|
49
|
+
|
50
|
+
#undef HAVE_PIPE2
|
51
|
+
#undef HAVE_ACCEPT4
|
52
|
+
|
53
|
+
/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
|
54
|
+
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
|
55
|
+
#define HAVE_PIPE2
|
56
|
+
#endif
|
57
|
+
|
58
|
+
/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
|
59
|
+
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
|
60
|
+
#define HAVE_ACCEPT4
|
61
|
+
#endif
|
62
|
+
|
63
|
+
#endif /* __linux__ */
|
64
|
+
|
65
|
+
#ifdef __sun
|
66
|
+
# include <sys/types.h>
|
67
|
+
# include <sys/wait.h>
|
68
|
+
#endif
|
69
|
+
|
70
|
+
#if defined(__APPLE__)
|
71
|
+
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
|
72
|
+
#endif
|
73
|
+
|
74
|
+
#if defined(__FreeBSD__)
|
75
|
+
#include <sys/sysctl.h>
|
76
|
+
#include <sys/wait.h>
|
77
|
+
#endif
|
78
|
+
|
79
|
+
static uv_loop_t default_loop_struct;
|
80
|
+
static uv_loop_t* default_loop_ptr;
|
81
|
+
|
82
|
+
void uv__next(EV_P_ ev_idle* watcher, int revents);
|
83
|
+
static void uv__finish_close(uv_handle_t* handle);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
#ifndef __GNUC__
|
88
|
+
#define __attribute__(a)
|
89
|
+
#endif
|
90
|
+
|
91
|
+
|
92
|
+
void uv_init() {
|
93
|
+
default_loop_ptr = &default_loop_struct;
|
94
|
+
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
|
95
|
+
default_loop_struct.ev = ev_default_loop(EVBACKEND_KQUEUE);
|
96
|
+
#else
|
97
|
+
default_loop_struct.ev = ev_default_loop(EVFLAG_AUTO);
|
98
|
+
#endif
|
99
|
+
ev_set_userdata(default_loop_struct.ev, default_loop_ptr);
|
100
|
+
}
|
101
|
+
|
102
|
+
|
103
|
+
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
104
|
+
uv_udp_t* udp;
|
105
|
+
uv_async_t* async;
|
106
|
+
uv_timer_t* timer;
|
107
|
+
uv_stream_t* stream;
|
108
|
+
uv_process_t* process;
|
109
|
+
|
110
|
+
handle->close_cb = close_cb;
|
111
|
+
|
112
|
+
switch (handle->type) {
|
113
|
+
case UV_NAMED_PIPE:
|
114
|
+
uv_pipe_cleanup((uv_pipe_t*)handle);
|
115
|
+
/* Fall through. */
|
116
|
+
|
117
|
+
case UV_TCP:
|
118
|
+
stream = (uv_stream_t*)handle;
|
119
|
+
|
120
|
+
uv_read_stop(stream);
|
121
|
+
ev_io_stop(stream->loop->ev, &stream->write_watcher);
|
122
|
+
|
123
|
+
uv__close(stream->fd);
|
124
|
+
stream->fd = -1;
|
125
|
+
|
126
|
+
if (stream->accepted_fd >= 0) {
|
127
|
+
uv__close(stream->accepted_fd);
|
128
|
+
stream->accepted_fd = -1;
|
129
|
+
}
|
130
|
+
|
131
|
+
assert(!ev_is_active(&stream->read_watcher));
|
132
|
+
assert(!ev_is_active(&stream->write_watcher));
|
133
|
+
break;
|
134
|
+
|
135
|
+
case UV_UDP:
|
136
|
+
udp = (uv_udp_t*)handle;
|
137
|
+
uv__udp_watcher_stop(udp, &udp->read_watcher);
|
138
|
+
uv__udp_watcher_stop(udp, &udp->write_watcher);
|
139
|
+
uv__close(udp->fd);
|
140
|
+
udp->fd = -1;
|
141
|
+
break;
|
142
|
+
|
143
|
+
case UV_PREPARE:
|
144
|
+
uv_prepare_stop((uv_prepare_t*) handle);
|
145
|
+
break;
|
146
|
+
|
147
|
+
case UV_CHECK:
|
148
|
+
uv_check_stop((uv_check_t*) handle);
|
149
|
+
break;
|
150
|
+
|
151
|
+
case UV_IDLE:
|
152
|
+
uv_idle_stop((uv_idle_t*) handle);
|
153
|
+
break;
|
154
|
+
|
155
|
+
case UV_ASYNC:
|
156
|
+
async = (uv_async_t*)handle;
|
157
|
+
ev_async_stop(async->loop->ev, &async->async_watcher);
|
158
|
+
ev_ref(async->loop->ev);
|
159
|
+
break;
|
160
|
+
|
161
|
+
case UV_TIMER:
|
162
|
+
timer = (uv_timer_t*)handle;
|
163
|
+
if (ev_is_active(&timer->timer_watcher)) {
|
164
|
+
ev_ref(timer->loop->ev);
|
165
|
+
}
|
166
|
+
ev_timer_stop(timer->loop->ev, &timer->timer_watcher);
|
167
|
+
break;
|
168
|
+
|
169
|
+
case UV_PROCESS:
|
170
|
+
process = (uv_process_t*)handle;
|
171
|
+
ev_child_stop(process->loop->ev, &process->child_watcher);
|
172
|
+
break;
|
173
|
+
|
174
|
+
default:
|
175
|
+
assert(0);
|
176
|
+
}
|
177
|
+
|
178
|
+
handle->flags |= UV_CLOSING;
|
179
|
+
|
180
|
+
/* This is used to call the on_close callback in the next loop. */
|
181
|
+
ev_idle_start(handle->loop->ev, &handle->next_watcher);
|
182
|
+
ev_feed_event(handle->loop->ev, &handle->next_watcher, EV_IDLE);
|
183
|
+
assert(ev_is_pending(&handle->next_watcher));
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
uv_loop_t* uv_loop_new() {
|
188
|
+
uv_loop_t* loop = calloc(1, sizeof(uv_loop_t));
|
189
|
+
loop->ev = ev_loop_new(0);
|
190
|
+
ev_set_userdata(loop->ev, loop);
|
191
|
+
return loop;
|
192
|
+
}
|
193
|
+
|
194
|
+
|
195
|
+
void uv_loop_delete(uv_loop_t* loop) {
|
196
|
+
uv_ares_destroy(loop, loop->channel);
|
197
|
+
ev_loop_destroy(loop->ev);
|
198
|
+
free(loop);
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
uv_loop_t* uv_default_loop() {
|
203
|
+
assert(default_loop_ptr->ev == EV_DEFAULT_UC);
|
204
|
+
return default_loop_ptr;
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
int uv_run(uv_loop_t* loop) {
|
209
|
+
ev_run(loop->ev, 0);
|
210
|
+
return 0;
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle,
|
215
|
+
uv_handle_type type) {
|
216
|
+
loop->counters.handle_init++;
|
217
|
+
|
218
|
+
handle->loop = loop;
|
219
|
+
handle->type = type;
|
220
|
+
handle->flags = 0;
|
221
|
+
|
222
|
+
ev_init(&handle->next_watcher, uv__next);
|
223
|
+
handle->next_watcher.data = handle;
|
224
|
+
|
225
|
+
/* Ref the loop until this handle is closed. See uv__finish_close. */
|
226
|
+
ev_ref(loop->ev);
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
void uv__finish_close(uv_handle_t* handle) {
|
231
|
+
uv_loop_t* loop = handle->loop;
|
232
|
+
|
233
|
+
assert(handle->flags & UV_CLOSING);
|
234
|
+
assert(!(handle->flags & UV_CLOSED));
|
235
|
+
handle->flags |= UV_CLOSED;
|
236
|
+
|
237
|
+
switch (handle->type) {
|
238
|
+
case UV_PREPARE:
|
239
|
+
assert(!ev_is_active(&((uv_prepare_t*)handle)->prepare_watcher));
|
240
|
+
break;
|
241
|
+
|
242
|
+
case UV_CHECK:
|
243
|
+
assert(!ev_is_active(&((uv_check_t*)handle)->check_watcher));
|
244
|
+
break;
|
245
|
+
|
246
|
+
case UV_IDLE:
|
247
|
+
assert(!ev_is_active(&((uv_idle_t*)handle)->idle_watcher));
|
248
|
+
break;
|
249
|
+
|
250
|
+
case UV_ASYNC:
|
251
|
+
assert(!ev_is_active(&((uv_async_t*)handle)->async_watcher));
|
252
|
+
break;
|
253
|
+
|
254
|
+
case UV_TIMER:
|
255
|
+
assert(!ev_is_active(&((uv_timer_t*)handle)->timer_watcher));
|
256
|
+
break;
|
257
|
+
|
258
|
+
case UV_NAMED_PIPE:
|
259
|
+
case UV_TCP:
|
260
|
+
assert(!ev_is_active(&((uv_stream_t*)handle)->read_watcher));
|
261
|
+
assert(!ev_is_active(&((uv_stream_t*)handle)->write_watcher));
|
262
|
+
break;
|
263
|
+
|
264
|
+
case UV_UDP:
|
265
|
+
assert(!ev_is_active(&((uv_udp_t*)handle)->read_watcher));
|
266
|
+
assert(!ev_is_active(&((uv_udp_t*)handle)->write_watcher));
|
267
|
+
assert(((uv_udp_t*)handle)->fd == -1);
|
268
|
+
uv__udp_destroy((uv_udp_t*)handle);
|
269
|
+
break;
|
270
|
+
|
271
|
+
case UV_PROCESS:
|
272
|
+
assert(!ev_is_active(&((uv_process_t*)handle)->child_watcher));
|
273
|
+
break;
|
274
|
+
|
275
|
+
default:
|
276
|
+
assert(0);
|
277
|
+
break;
|
278
|
+
}
|
279
|
+
|
280
|
+
ev_idle_stop(loop->ev, &handle->next_watcher);
|
281
|
+
|
282
|
+
if (handle->close_cb) {
|
283
|
+
handle->close_cb(handle);
|
284
|
+
}
|
285
|
+
|
286
|
+
ev_unref(loop->ev);
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
void uv__next(EV_P_ ev_idle* watcher, int revents) {
|
291
|
+
uv_handle_t* handle = watcher->data;
|
292
|
+
assert(watcher == &handle->next_watcher);
|
293
|
+
assert(revents == EV_IDLE);
|
294
|
+
|
295
|
+
/* For now this function is only to handle the closing event, but we might
|
296
|
+
* put more stuff here later.
|
297
|
+
*/
|
298
|
+
assert(handle->flags & UV_CLOSING);
|
299
|
+
uv__finish_close(handle);
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
int uv_getsockname(uv_handle_t* handle, struct sockaddr* name, int* namelen) {
|
304
|
+
socklen_t socklen;
|
305
|
+
int saved_errno;
|
306
|
+
|
307
|
+
/* Don't clobber errno. */
|
308
|
+
saved_errno = errno;
|
309
|
+
|
310
|
+
/* sizeof(socklen_t) != sizeof(int) on some systems. */
|
311
|
+
socklen = (socklen_t)*namelen;
|
312
|
+
|
313
|
+
if (getsockname(handle->fd, name, &socklen) == -1) {
|
314
|
+
uv_err_new(handle->loop, errno);
|
315
|
+
} else {
|
316
|
+
*namelen = (int)socklen;
|
317
|
+
}
|
318
|
+
|
319
|
+
errno = saved_errno;
|
320
|
+
return 0;
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
void uv_ref(uv_loop_t* loop) {
|
325
|
+
ev_ref(loop->ev);
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
void uv_unref(uv_loop_t* loop) {
|
330
|
+
ev_unref(loop->ev);
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
void uv_update_time(uv_loop_t* loop) {
|
335
|
+
ev_now_update(loop->ev);
|
336
|
+
}
|
337
|
+
|
338
|
+
|
339
|
+
int64_t uv_now(uv_loop_t* loop) {
|
340
|
+
return (int64_t)(ev_now(loop->ev) * 1000);
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
void uv__req_init(uv_req_t* req) {
|
345
|
+
/* loop->counters.req_init++; */
|
346
|
+
req->type = UV_UNKNOWN_REQ;
|
347
|
+
req->data = NULL;
|
348
|
+
}
|
349
|
+
|
350
|
+
|
351
|
+
static void uv__prepare(EV_P_ ev_prepare* w, int revents) {
|
352
|
+
uv_prepare_t* prepare = w->data;
|
353
|
+
|
354
|
+
if (prepare->prepare_cb) {
|
355
|
+
prepare->prepare_cb(prepare, 0);
|
356
|
+
}
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) {
|
361
|
+
uv__handle_init(loop, (uv_handle_t*)prepare, UV_PREPARE);
|
362
|
+
loop->counters.prepare_init++;
|
363
|
+
|
364
|
+
ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
|
365
|
+
prepare->prepare_watcher.data = prepare;
|
366
|
+
|
367
|
+
prepare->prepare_cb = NULL;
|
368
|
+
|
369
|
+
return 0;
|
370
|
+
}
|
371
|
+
|
372
|
+
|
373
|
+
int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb) {
|
374
|
+
int was_active = ev_is_active(&prepare->prepare_watcher);
|
375
|
+
|
376
|
+
prepare->prepare_cb = cb;
|
377
|
+
|
378
|
+
ev_prepare_start(prepare->loop->ev, &prepare->prepare_watcher);
|
379
|
+
|
380
|
+
if (!was_active) {
|
381
|
+
ev_unref(prepare->loop->ev);
|
382
|
+
}
|
383
|
+
|
384
|
+
return 0;
|
385
|
+
}
|
386
|
+
|
387
|
+
|
388
|
+
int uv_prepare_stop(uv_prepare_t* prepare) {
|
389
|
+
int was_active = ev_is_active(&prepare->prepare_watcher);
|
390
|
+
|
391
|
+
ev_prepare_stop(prepare->loop->ev, &prepare->prepare_watcher);
|
392
|
+
|
393
|
+
if (was_active) {
|
394
|
+
ev_ref(prepare->loop->ev);
|
395
|
+
}
|
396
|
+
return 0;
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
static void uv__check(EV_P_ ev_check* w, int revents) {
|
402
|
+
uv_check_t* check = w->data;
|
403
|
+
|
404
|
+
if (check->check_cb) {
|
405
|
+
check->check_cb(check, 0);
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
int uv_check_init(uv_loop_t* loop, uv_check_t* check) {
|
411
|
+
uv__handle_init(loop, (uv_handle_t*)check, UV_CHECK);
|
412
|
+
loop->counters.check_init++;
|
413
|
+
|
414
|
+
ev_check_init(&check->check_watcher, uv__check);
|
415
|
+
check->check_watcher.data = check;
|
416
|
+
|
417
|
+
check->check_cb = NULL;
|
418
|
+
|
419
|
+
return 0;
|
420
|
+
}
|
421
|
+
|
422
|
+
|
423
|
+
int uv_check_start(uv_check_t* check, uv_check_cb cb) {
|
424
|
+
int was_active = ev_is_active(&check->check_watcher);
|
425
|
+
|
426
|
+
check->check_cb = cb;
|
427
|
+
|
428
|
+
ev_check_start(check->loop->ev, &check->check_watcher);
|
429
|
+
|
430
|
+
if (!was_active) {
|
431
|
+
ev_unref(check->loop->ev);
|
432
|
+
}
|
433
|
+
|
434
|
+
return 0;
|
435
|
+
}
|
436
|
+
|
437
|
+
|
438
|
+
int uv_check_stop(uv_check_t* check) {
|
439
|
+
int was_active = ev_is_active(&check->check_watcher);
|
440
|
+
|
441
|
+
ev_check_stop(check->loop->ev, &check->check_watcher);
|
442
|
+
|
443
|
+
if (was_active) {
|
444
|
+
ev_ref(check->loop->ev);
|
445
|
+
}
|
446
|
+
|
447
|
+
return 0;
|
448
|
+
}
|
449
|
+
|
450
|
+
|
451
|
+
static void uv__idle(EV_P_ ev_idle* w, int revents) {
|
452
|
+
uv_idle_t* idle = (uv_idle_t*)(w->data);
|
453
|
+
|
454
|
+
if (idle->idle_cb) {
|
455
|
+
idle->idle_cb(idle, 0);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
int uv_idle_init(uv_loop_t* loop, uv_idle_t* idle) {
|
462
|
+
uv__handle_init(loop, (uv_handle_t*)idle, UV_IDLE);
|
463
|
+
loop->counters.idle_init++;
|
464
|
+
|
465
|
+
ev_idle_init(&idle->idle_watcher, uv__idle);
|
466
|
+
idle->idle_watcher.data = idle;
|
467
|
+
|
468
|
+
idle->idle_cb = NULL;
|
469
|
+
|
470
|
+
return 0;
|
471
|
+
}
|
472
|
+
|
473
|
+
|
474
|
+
int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb) {
|
475
|
+
int was_active = ev_is_active(&idle->idle_watcher);
|
476
|
+
|
477
|
+
idle->idle_cb = cb;
|
478
|
+
ev_idle_start(idle->loop->ev, &idle->idle_watcher);
|
479
|
+
|
480
|
+
if (!was_active) {
|
481
|
+
ev_unref(idle->loop->ev);
|
482
|
+
}
|
483
|
+
|
484
|
+
return 0;
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
int uv_idle_stop(uv_idle_t* idle) {
|
489
|
+
int was_active = ev_is_active(&idle->idle_watcher);
|
490
|
+
|
491
|
+
ev_idle_stop(idle->loop->ev, &idle->idle_watcher);
|
492
|
+
|
493
|
+
if (was_active) {
|
494
|
+
ev_ref(idle->loop->ev);
|
495
|
+
}
|
496
|
+
|
497
|
+
return 0;
|
498
|
+
}
|
499
|
+
|
500
|
+
|
501
|
+
int uv_is_active(uv_handle_t* handle) {
|
502
|
+
switch (handle->type) {
|
503
|
+
case UV_TIMER:
|
504
|
+
return ev_is_active(&((uv_timer_t*)handle)->timer_watcher);
|
505
|
+
|
506
|
+
case UV_PREPARE:
|
507
|
+
return ev_is_active(&((uv_prepare_t*)handle)->prepare_watcher);
|
508
|
+
|
509
|
+
case UV_CHECK:
|
510
|
+
return ev_is_active(&((uv_check_t*)handle)->check_watcher);
|
511
|
+
|
512
|
+
case UV_IDLE:
|
513
|
+
return ev_is_active(&((uv_idle_t*)handle)->idle_watcher);
|
514
|
+
|
515
|
+
default:
|
516
|
+
return 1;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
|
520
|
+
|
521
|
+
static void uv__async(EV_P_ ev_async* w, int revents) {
|
522
|
+
uv_async_t* async = w->data;
|
523
|
+
|
524
|
+
if (async->async_cb) {
|
525
|
+
async->async_cb(async, 0);
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
529
|
+
|
530
|
+
int uv_async_init(uv_loop_t* loop, uv_async_t* async, uv_async_cb async_cb) {
|
531
|
+
uv__handle_init(loop, (uv_handle_t*)async, UV_ASYNC);
|
532
|
+
loop->counters.async_init++;
|
533
|
+
|
534
|
+
ev_async_init(&async->async_watcher, uv__async);
|
535
|
+
async->async_watcher.data = async;
|
536
|
+
|
537
|
+
async->async_cb = async_cb;
|
538
|
+
|
539
|
+
/* Note: This does not have symmetry with the other libev wrappers. */
|
540
|
+
ev_async_start(loop->ev, &async->async_watcher);
|
541
|
+
ev_unref(loop->ev);
|
542
|
+
|
543
|
+
return 0;
|
544
|
+
}
|
545
|
+
|
546
|
+
|
547
|
+
int uv_async_send(uv_async_t* async) {
|
548
|
+
ev_async_send(async->loop->ev, &async->async_watcher);
|
549
|
+
return 0;
|
550
|
+
}
|
551
|
+
|
552
|
+
|
553
|
+
static void uv__timer_cb(EV_P_ ev_timer* w, int revents) {
|
554
|
+
uv_timer_t* timer = w->data;
|
555
|
+
|
556
|
+
if (!ev_is_active(w)) {
|
557
|
+
ev_ref(EV_A);
|
558
|
+
}
|
559
|
+
|
560
|
+
if (timer->timer_cb) {
|
561
|
+
timer->timer_cb(timer, 0);
|
562
|
+
}
|
563
|
+
}
|
564
|
+
|
565
|
+
|
566
|
+
int uv_timer_init(uv_loop_t* loop, uv_timer_t* timer) {
|
567
|
+
uv__handle_init(loop, (uv_handle_t*)timer, UV_TIMER);
|
568
|
+
loop->counters.timer_init++;
|
569
|
+
|
570
|
+
ev_init(&timer->timer_watcher, uv__timer_cb);
|
571
|
+
timer->timer_watcher.data = timer;
|
572
|
+
|
573
|
+
return 0;
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
int uv_timer_start(uv_timer_t* timer, uv_timer_cb cb, int64_t timeout,
|
578
|
+
int64_t repeat) {
|
579
|
+
if (ev_is_active(&timer->timer_watcher)) {
|
580
|
+
return -1;
|
581
|
+
}
|
582
|
+
|
583
|
+
timer->timer_cb = cb;
|
584
|
+
ev_timer_set(&timer->timer_watcher, timeout / 1000.0, repeat / 1000.0);
|
585
|
+
ev_timer_start(timer->loop->ev, &timer->timer_watcher);
|
586
|
+
ev_unref(timer->loop->ev);
|
587
|
+
return 0;
|
588
|
+
}
|
589
|
+
|
590
|
+
|
591
|
+
int uv_timer_stop(uv_timer_t* timer) {
|
592
|
+
if (ev_is_active(&timer->timer_watcher)) {
|
593
|
+
ev_ref(timer->loop->ev);
|
594
|
+
}
|
595
|
+
|
596
|
+
ev_timer_stop(timer->loop->ev, &timer->timer_watcher);
|
597
|
+
return 0;
|
598
|
+
}
|
599
|
+
|
600
|
+
|
601
|
+
int uv_timer_again(uv_timer_t* timer) {
|
602
|
+
if (!ev_is_active(&timer->timer_watcher)) {
|
603
|
+
uv_err_new(timer->loop, EINVAL);
|
604
|
+
return -1;
|
605
|
+
}
|
606
|
+
|
607
|
+
ev_timer_again(timer->loop->ev, &timer->timer_watcher);
|
608
|
+
return 0;
|
609
|
+
}
|
610
|
+
|
611
|
+
void uv_timer_set_repeat(uv_timer_t* timer, int64_t repeat) {
|
612
|
+
assert(timer->type == UV_TIMER);
|
613
|
+
timer->timer_watcher.repeat = repeat / 1000.0;
|
614
|
+
}
|
615
|
+
|
616
|
+
int64_t uv_timer_get_repeat(uv_timer_t* timer) {
|
617
|
+
assert(timer->type == UV_TIMER);
|
618
|
+
return (int64_t)(1000 * timer->timer_watcher.repeat);
|
619
|
+
}
|
620
|
+
|
621
|
+
|
622
|
+
static int uv_getaddrinfo_done(eio_req* req) {
|
623
|
+
uv_getaddrinfo_t* handle = req->data;
|
624
|
+
|
625
|
+
uv_unref(handle->loop);
|
626
|
+
|
627
|
+
free(handle->hints);
|
628
|
+
free(handle->service);
|
629
|
+
free(handle->hostname);
|
630
|
+
|
631
|
+
if (handle->retcode != 0) {
|
632
|
+
/* TODO how to display gai error strings? */
|
633
|
+
uv_err_new(handle->loop, handle->retcode);
|
634
|
+
}
|
635
|
+
|
636
|
+
handle->cb(handle, handle->retcode, handle->res);
|
637
|
+
|
638
|
+
freeaddrinfo(handle->res);
|
639
|
+
handle->res = NULL;
|
640
|
+
|
641
|
+
return 0;
|
642
|
+
}
|
643
|
+
|
644
|
+
|
645
|
+
static void getaddrinfo_thread_proc(eio_req *req) {
|
646
|
+
uv_getaddrinfo_t* handle = req->data;
|
647
|
+
|
648
|
+
handle->retcode = getaddrinfo(handle->hostname,
|
649
|
+
handle->service,
|
650
|
+
handle->hints,
|
651
|
+
&handle->res);
|
652
|
+
}
|
653
|
+
|
654
|
+
|
655
|
+
/* stub implementation of uv_getaddrinfo */
|
656
|
+
int uv_getaddrinfo(uv_loop_t* loop,
|
657
|
+
uv_getaddrinfo_t* handle,
|
658
|
+
uv_getaddrinfo_cb cb,
|
659
|
+
const char* hostname,
|
660
|
+
const char* service,
|
661
|
+
const struct addrinfo* hints) {
|
662
|
+
eio_req* req;
|
663
|
+
uv_eio_init(loop);
|
664
|
+
|
665
|
+
if (handle == NULL || cb == NULL ||
|
666
|
+
(hostname == NULL && service == NULL)) {
|
667
|
+
uv_err_new_artificial(loop, UV_EINVAL);
|
668
|
+
return -1;
|
669
|
+
}
|
670
|
+
|
671
|
+
memset(handle, 0, sizeof(uv_getaddrinfo_t));
|
672
|
+
|
673
|
+
/* TODO don't alloc so much. */
|
674
|
+
|
675
|
+
if (hints) {
|
676
|
+
handle->hints = malloc(sizeof(struct addrinfo));
|
677
|
+
memcpy(&handle->hints, hints, sizeof(struct addrinfo));
|
678
|
+
}
|
679
|
+
|
680
|
+
/* TODO security! check lengths, check return values. */
|
681
|
+
|
682
|
+
handle->loop = loop;
|
683
|
+
handle->cb = cb;
|
684
|
+
handle->hostname = hostname ? strdup(hostname) : NULL;
|
685
|
+
handle->service = service ? strdup(service) : NULL;
|
686
|
+
|
687
|
+
/* TODO check handle->hostname == NULL */
|
688
|
+
/* TODO check handle->service == NULL */
|
689
|
+
|
690
|
+
uv_ref(loop);
|
691
|
+
|
692
|
+
req = eio_custom(getaddrinfo_thread_proc, EIO_PRI_DEFAULT,
|
693
|
+
uv_getaddrinfo_done, handle);
|
694
|
+
assert(req);
|
695
|
+
assert(req->data == handle);
|
696
|
+
|
697
|
+
return 0;
|
698
|
+
}
|
699
|
+
|
700
|
+
|
701
|
+
/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */
|
702
|
+
int uv__socket(int domain, int type, int protocol) {
|
703
|
+
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
|
704
|
+
return socket(domain, type | SOCK_NONBLOCK | SOCK_CLOEXEC, protocol);
|
705
|
+
#else
|
706
|
+
int sockfd;
|
707
|
+
|
708
|
+
if ((sockfd = socket(domain, type, protocol)) == -1) {
|
709
|
+
return -1;
|
710
|
+
}
|
711
|
+
|
712
|
+
if (uv__nonblock(sockfd, 1) == -1 || uv__cloexec(sockfd, 1) == -1) {
|
713
|
+
uv__close(sockfd);
|
714
|
+
return -1;
|
715
|
+
}
|
716
|
+
|
717
|
+
return sockfd;
|
718
|
+
#endif
|
719
|
+
}
|
720
|
+
|
721
|
+
|
722
|
+
int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t slen) {
|
723
|
+
int peerfd;
|
724
|
+
|
725
|
+
assert(sockfd >= 0);
|
726
|
+
|
727
|
+
do {
|
728
|
+
#if defined(HAVE_ACCEPT4)
|
729
|
+
peerfd = accept4(sockfd, saddr, &slen, SOCK_NONBLOCK | SOCK_CLOEXEC);
|
730
|
+
#else
|
731
|
+
if ((peerfd = accept(sockfd, saddr, &slen)) != -1) {
|
732
|
+
if (uv__cloexec(peerfd, 1) == -1 || uv__nonblock(peerfd, 1) == -1) {
|
733
|
+
uv__close(peerfd);
|
734
|
+
return -1;
|
735
|
+
}
|
736
|
+
}
|
737
|
+
#endif
|
738
|
+
}
|
739
|
+
while (peerfd == -1 && errno == EINTR);
|
740
|
+
|
741
|
+
return peerfd;
|
742
|
+
}
|
743
|
+
|
744
|
+
|
745
|
+
int uv__close(int fd) {
|
746
|
+
int status;
|
747
|
+
|
748
|
+
/*
|
749
|
+
* Retry on EINTR. You may think this is academic but on linux
|
750
|
+
* and probably other Unices too, close(2) is interruptible.
|
751
|
+
* Failing to handle EINTR is a common source of fd leaks.
|
752
|
+
*/
|
753
|
+
do {
|
754
|
+
status = close(fd);
|
755
|
+
}
|
756
|
+
while (status == -1 && errno == EINTR);
|
757
|
+
|
758
|
+
return status;
|
759
|
+
}
|
760
|
+
|
761
|
+
|
762
|
+
int uv__nonblock(int fd, int set) {
|
763
|
+
int flags;
|
764
|
+
|
765
|
+
if ((flags = fcntl(fd, F_GETFL)) == -1) {
|
766
|
+
return -1;
|
767
|
+
}
|
768
|
+
|
769
|
+
if (set) {
|
770
|
+
flags |= O_NONBLOCK;
|
771
|
+
} else {
|
772
|
+
flags &= ~O_NONBLOCK;
|
773
|
+
}
|
774
|
+
|
775
|
+
if (fcntl(fd, F_SETFL, flags) == -1) {
|
776
|
+
return -1;
|
777
|
+
}
|
778
|
+
|
779
|
+
return 0;
|
780
|
+
}
|
781
|
+
|
782
|
+
|
783
|
+
int uv__cloexec(int fd, int set) {
|
784
|
+
int flags;
|
785
|
+
|
786
|
+
if ((flags = fcntl(fd, F_GETFD)) == -1) {
|
787
|
+
return -1;
|
788
|
+
}
|
789
|
+
|
790
|
+
if (set) {
|
791
|
+
flags |= FD_CLOEXEC;
|
792
|
+
} else {
|
793
|
+
flags &= ~FD_CLOEXEC;
|
794
|
+
}
|
795
|
+
|
796
|
+
if (fcntl(fd, F_SETFD, flags) == -1) {
|
797
|
+
return -1;
|
798
|
+
}
|
799
|
+
|
800
|
+
return 0;
|
801
|
+
}
|
802
|
+
|
803
|
+
|
804
|
+
/* TODO move to uv-common.c? */
|
805
|
+
size_t uv__strlcpy(char* dst, const char* src, size_t size) {
|
806
|
+
const char *org;
|
807
|
+
|
808
|
+
if (size == 0) {
|
809
|
+
return 0;
|
810
|
+
}
|
811
|
+
|
812
|
+
org = src;
|
813
|
+
while (size > 1) {
|
814
|
+
if ((*dst++ = *src++) == '\0') {
|
815
|
+
return org - src;
|
816
|
+
}
|
817
|
+
}
|
818
|
+
*dst = '\0';
|
819
|
+
|
820
|
+
return src - org;
|
821
|
+
}
|
822
|
+
|
823
|
+
|
824
|
+
uv_stream_t* uv_std_handle(uv_loop_t* loop, uv_std_type type) {
|
825
|
+
assert(0 && "implement me");
|
826
|
+
return NULL;
|
827
|
+
}
|
828
|
+
|