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,592 @@
|
|
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
|
+
|
24
|
+
#include "uv.h"
|
25
|
+
#include "../uv-common.h"
|
26
|
+
#include "internal.h"
|
27
|
+
#include <stdio.h>
|
28
|
+
|
29
|
+
#if 0
|
30
|
+
/*
|
31
|
+
* Threshold of active udp streams for which to preallocate udp read buffers.
|
32
|
+
*/
|
33
|
+
const unsigned int uv_active_udp_streams_threshold = 0;
|
34
|
+
|
35
|
+
/* A zero-size buffer for use by uv_udp_read */
|
36
|
+
static char uv_zero_[] = "";
|
37
|
+
#endif
|
38
|
+
|
39
|
+
/* Counter to keep track of active udp streams */
|
40
|
+
static unsigned int active_udp_streams = 0;
|
41
|
+
|
42
|
+
|
43
|
+
int uv_udp_getsockname(uv_loop_t* loop, uv_udp_t* handle,
|
44
|
+
struct sockaddr* name, int* namelen) {
|
45
|
+
int result;
|
46
|
+
|
47
|
+
result = getsockname(handle->socket, name, namelen);
|
48
|
+
if (result != 0) {
|
49
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
50
|
+
return -1;
|
51
|
+
}
|
52
|
+
|
53
|
+
return 0;
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle,
|
58
|
+
SOCKET socket) {
|
59
|
+
DWORD yes = 1;
|
60
|
+
|
61
|
+
assert(handle->socket == INVALID_SOCKET);
|
62
|
+
|
63
|
+
/* Set the socket to nonblocking mode */
|
64
|
+
if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR) {
|
65
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
66
|
+
return -1;
|
67
|
+
}
|
68
|
+
|
69
|
+
/* Make the socket non-inheritable */
|
70
|
+
if (!SetHandleInformation((HANDLE)socket, HANDLE_FLAG_INHERIT, 0)) {
|
71
|
+
uv_set_sys_error(loop, GetLastError());
|
72
|
+
return -1;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* Associate it with the I/O completion port. */
|
76
|
+
/* Use uv_handle_t pointer as completion key. */
|
77
|
+
if (CreateIoCompletionPort((HANDLE)socket,
|
78
|
+
loop->iocp,
|
79
|
+
(ULONG_PTR)socket,
|
80
|
+
0) == NULL) {
|
81
|
+
uv_set_sys_error(loop, GetLastError());
|
82
|
+
return -1;
|
83
|
+
}
|
84
|
+
|
85
|
+
if (pSetFileCompletionNotificationModes) {
|
86
|
+
if (!pSetFileCompletionNotificationModes((HANDLE)socket,
|
87
|
+
FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
|
88
|
+
uv_set_sys_error(loop, GetLastError());
|
89
|
+
return -1;
|
90
|
+
}
|
91
|
+
|
92
|
+
handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
|
93
|
+
}
|
94
|
+
|
95
|
+
handle->socket = socket;
|
96
|
+
|
97
|
+
return 0;
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
|
102
|
+
handle->type = UV_UDP;
|
103
|
+
handle->socket = INVALID_SOCKET;
|
104
|
+
handle->reqs_pending = 0;
|
105
|
+
handle->loop = loop;
|
106
|
+
handle->flags = 0;
|
107
|
+
|
108
|
+
uv_req_init(loop, (uv_req_t*) &(handle->recv_req));
|
109
|
+
handle->recv_req.type = UV_UDP_RECV;
|
110
|
+
handle->recv_req.data = handle;
|
111
|
+
|
112
|
+
uv_ref(loop);
|
113
|
+
|
114
|
+
loop->counters.handle_init++;
|
115
|
+
loop->counters.udp_init++;
|
116
|
+
|
117
|
+
return 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) {
|
122
|
+
if (handle->flags & UV_HANDLE_CLOSING &&
|
123
|
+
handle->reqs_pending == 0) {
|
124
|
+
assert(!(handle->flags & UV_HANDLE_CLOSED));
|
125
|
+
handle->flags |= UV_HANDLE_CLOSED;
|
126
|
+
|
127
|
+
if (handle->close_cb) {
|
128
|
+
handle->close_cb((uv_handle_t*)handle);
|
129
|
+
}
|
130
|
+
|
131
|
+
uv_unref(loop);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
static int uv__bind(uv_udp_t* handle, int domain, struct sockaddr* addr,
|
137
|
+
int addrsize, unsigned int flags) {
|
138
|
+
uv_loop_t* loop = handle->loop;
|
139
|
+
DWORD err;
|
140
|
+
int r;
|
141
|
+
SOCKET sock;
|
142
|
+
|
143
|
+
if ((flags & UV_UDP_IPV6ONLY) && domain != AF_INET6) {
|
144
|
+
/* UV_UDP_IPV6ONLY is supported only for IPV6 sockets */
|
145
|
+
uv_set_sys_error(loop, UV_EINVAL);
|
146
|
+
}
|
147
|
+
|
148
|
+
if (handle->socket == INVALID_SOCKET) {
|
149
|
+
sock = socket(domain, SOCK_DGRAM, 0);
|
150
|
+
if (sock == INVALID_SOCKET) {
|
151
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
152
|
+
return -1;
|
153
|
+
}
|
154
|
+
|
155
|
+
if (uv_udp_set_socket(loop, handle, sock) == -1) {
|
156
|
+
closesocket(sock);
|
157
|
+
return -1;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
if (domain == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) {
|
162
|
+
DWORD off = 0;
|
163
|
+
/* On windows IPV6ONLY is on by default. */
|
164
|
+
/* If the user doesn't specify it libuv turns it off. */
|
165
|
+
|
166
|
+
/* TODO: how to handle errors? This may fail if there is no ipv4 stack */
|
167
|
+
/* available, or when run on XP/2003 which have no support for dualstack */
|
168
|
+
/* sockets. For now we're silently ignoring the error. */
|
169
|
+
setsockopt(sock,
|
170
|
+
IPPROTO_IPV6,
|
171
|
+
IPV6_V6ONLY,
|
172
|
+
(const char*) &off,
|
173
|
+
sizeof off);
|
174
|
+
}
|
175
|
+
|
176
|
+
r = bind(handle->socket, addr, addrsize);
|
177
|
+
|
178
|
+
if (r == SOCKET_ERROR) {
|
179
|
+
err = WSAGetLastError();
|
180
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
181
|
+
return -1;
|
182
|
+
}
|
183
|
+
|
184
|
+
handle->flags |= UV_HANDLE_BOUND;
|
185
|
+
|
186
|
+
return 0;
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
|
191
|
+
unsigned int flags) {
|
192
|
+
uv_loop_t* loop = handle->loop;
|
193
|
+
|
194
|
+
if (addr.sin_family != AF_INET) {
|
195
|
+
uv_set_sys_error(loop, WSAEFAULT);
|
196
|
+
return -1;
|
197
|
+
}
|
198
|
+
|
199
|
+
return uv__bind(handle,
|
200
|
+
AF_INET,
|
201
|
+
(struct sockaddr*) &addr,
|
202
|
+
sizeof(struct sockaddr_in),
|
203
|
+
flags);
|
204
|
+
}
|
205
|
+
|
206
|
+
|
207
|
+
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
|
208
|
+
unsigned int flags) {
|
209
|
+
uv_loop_t* loop = handle->loop;
|
210
|
+
|
211
|
+
if (addr.sin6_family != AF_INET6) {
|
212
|
+
uv_set_sys_error(loop, WSAEFAULT);
|
213
|
+
return -1;
|
214
|
+
}
|
215
|
+
|
216
|
+
if (uv_allow_ipv6) {
|
217
|
+
handle->flags |= UV_HANDLE_IPV6;
|
218
|
+
return uv__bind(handle,
|
219
|
+
AF_INET6,
|
220
|
+
(struct sockaddr*) &addr,
|
221
|
+
sizeof(struct sockaddr_in6),
|
222
|
+
flags);
|
223
|
+
} else {
|
224
|
+
uv_new_sys_error(WSAEAFNOSUPPORT);
|
225
|
+
return -1;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
static void uv_udp_queue_recv(uv_loop_t* loop, uv_udp_t* handle) {
|
231
|
+
uv_req_t* req;
|
232
|
+
uv_buf_t buf;
|
233
|
+
DWORD bytes, flags;
|
234
|
+
int result;
|
235
|
+
|
236
|
+
assert(handle->flags & UV_HANDLE_READING);
|
237
|
+
assert(!(handle->flags & UV_HANDLE_READ_PENDING));
|
238
|
+
|
239
|
+
req = &handle->recv_req;
|
240
|
+
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
241
|
+
|
242
|
+
/*
|
243
|
+
* Preallocate a read buffer if the number of active streams is below
|
244
|
+
* the threshold.
|
245
|
+
*/
|
246
|
+
#if 0
|
247
|
+
if (active_udp_streams < uv_active_udp_streams_threshold) {
|
248
|
+
handle->flags &= ~UV_HANDLE_ZERO_READ;
|
249
|
+
#endif
|
250
|
+
handle->recv_buffer = handle->alloc_cb((uv_handle_t*) handle, 65536);
|
251
|
+
assert(handle->recv_buffer.len > 0);
|
252
|
+
|
253
|
+
buf = handle->recv_buffer;
|
254
|
+
memset(&handle->recv_from, 0, sizeof handle->recv_from);
|
255
|
+
handle->recv_from_len = sizeof handle->recv_from;
|
256
|
+
flags = 0;
|
257
|
+
|
258
|
+
result = WSARecvFrom(handle->socket,
|
259
|
+
(WSABUF*) &buf,
|
260
|
+
1,
|
261
|
+
&bytes,
|
262
|
+
&flags,
|
263
|
+
(struct sockaddr*) &handle->recv_from,
|
264
|
+
&handle->recv_from_len,
|
265
|
+
&req->overlapped,
|
266
|
+
NULL);
|
267
|
+
|
268
|
+
if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {
|
269
|
+
/* Process the req without IOCP. */
|
270
|
+
handle->flags |= UV_HANDLE_READ_PENDING;
|
271
|
+
req->overlapped.InternalHigh = bytes;
|
272
|
+
handle->reqs_pending++;
|
273
|
+
uv_insert_pending_req(loop, req);
|
274
|
+
} else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) {
|
275
|
+
/* The req will be processed with IOCP. */
|
276
|
+
handle->flags |= UV_HANDLE_READ_PENDING;
|
277
|
+
handle->reqs_pending++;
|
278
|
+
} else {
|
279
|
+
/* Make this req pending reporting an error. */
|
280
|
+
SET_REQ_ERROR(req, WSAGetLastError());
|
281
|
+
uv_insert_pending_req(loop, req);
|
282
|
+
handle->reqs_pending++;
|
283
|
+
}
|
284
|
+
#if 0
|
285
|
+
} else {
|
286
|
+
handle->flags |= UV_HANDLE_ZERO_READ;
|
287
|
+
|
288
|
+
buf.base = (char*) uv_zero_;
|
289
|
+
buf.len = 0;
|
290
|
+
flags = MSG_PARTIAL;
|
291
|
+
|
292
|
+
result = WSARecv(handle->socket,
|
293
|
+
(WSABUF*) &buf,
|
294
|
+
1,
|
295
|
+
&bytes,
|
296
|
+
&flags,
|
297
|
+
&req->overlapped,
|
298
|
+
NULL);
|
299
|
+
|
300
|
+
if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {
|
301
|
+
/* Process the req without IOCP. */
|
302
|
+
handle->flags |= UV_HANDLE_READ_PENDING;
|
303
|
+
req->overlapped.InternalHigh = bytes;
|
304
|
+
handle->reqs_pending++;
|
305
|
+
uv_insert_pending_req(loop, req);
|
306
|
+
} else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) {
|
307
|
+
/* The req will be processed with IOCP. */
|
308
|
+
handle->flags |= UV_HANDLE_READ_PENDING;
|
309
|
+
handle->reqs_pending++;
|
310
|
+
} else {
|
311
|
+
/* Make this req pending reporting an error. */
|
312
|
+
SET_REQ_ERROR(req, WSAGetLastError());
|
313
|
+
uv_insert_pending_req(loop, req);
|
314
|
+
handle->reqs_pending++;
|
315
|
+
}
|
316
|
+
}
|
317
|
+
#endif
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
int uv_udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
|
322
|
+
uv_udp_recv_cb recv_cb) {
|
323
|
+
uv_loop_t* loop = handle->loop;
|
324
|
+
|
325
|
+
if (handle->flags & UV_HANDLE_READING) {
|
326
|
+
uv_set_sys_error(loop, WSAEALREADY);
|
327
|
+
return -1;
|
328
|
+
}
|
329
|
+
|
330
|
+
if (!(handle->flags & UV_HANDLE_BOUND) &&
|
331
|
+
uv_udp_bind(handle, uv_addr_ip4_any_, 0) < 0) {
|
332
|
+
return -1;
|
333
|
+
}
|
334
|
+
|
335
|
+
handle->flags |= UV_HANDLE_READING;
|
336
|
+
active_udp_streams++;
|
337
|
+
|
338
|
+
handle->recv_cb = recv_cb;
|
339
|
+
handle->alloc_cb = alloc_cb;
|
340
|
+
|
341
|
+
/* If reading was stopped and then started again, there could stell be a */
|
342
|
+
/* recv request pending. */
|
343
|
+
if (!(handle->flags & UV_HANDLE_READ_PENDING))
|
344
|
+
uv_udp_queue_recv(loop, handle);
|
345
|
+
|
346
|
+
return 0;
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
int uv_udp_recv_stop(uv_udp_t* handle) {
|
351
|
+
if (handle->flags & UV_HANDLE_READING) {
|
352
|
+
handle->flags &= ~UV_HANDLE_READING;
|
353
|
+
active_udp_streams--;
|
354
|
+
}
|
355
|
+
|
356
|
+
return 0;
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
int uv_udp_connect6(uv_connect_t* req, uv_udp_t* handle,
|
361
|
+
struct sockaddr_in6 address, uv_connect_cb cb) {
|
362
|
+
uv_loop_t* loop = handle->loop;
|
363
|
+
int addrsize = sizeof(struct sockaddr_in6);
|
364
|
+
BOOL success;
|
365
|
+
DWORD bytes;
|
366
|
+
|
367
|
+
if (!uv_allow_ipv6) {
|
368
|
+
uv_new_sys_error(WSAEAFNOSUPPORT);
|
369
|
+
return -1;
|
370
|
+
}
|
371
|
+
|
372
|
+
if (address.sin6_family != AF_INET6) {
|
373
|
+
uv_set_sys_error(loop, WSAEFAULT);
|
374
|
+
return -1;
|
375
|
+
}
|
376
|
+
|
377
|
+
if (!(handle->flags & UV_HANDLE_BOUND) &&
|
378
|
+
uv_udp_bind6(handle, uv_addr_ip6_any_, 0) < 0)
|
379
|
+
return -1;
|
380
|
+
|
381
|
+
uv_req_init(loop, (uv_req_t*) req);
|
382
|
+
req->type = UV_CONNECT;
|
383
|
+
req->handle = (uv_stream_t*) handle;
|
384
|
+
req->cb = cb;
|
385
|
+
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
386
|
+
|
387
|
+
success = pConnectEx6(handle->socket,
|
388
|
+
(struct sockaddr*) &address,
|
389
|
+
addrsize,
|
390
|
+
NULL,
|
391
|
+
0,
|
392
|
+
&bytes,
|
393
|
+
&req->overlapped);
|
394
|
+
|
395
|
+
if (UV_SUCCEEDED_WITHOUT_IOCP(success)) {
|
396
|
+
handle->reqs_pending++;
|
397
|
+
uv_insert_pending_req(loop, (uv_req_t*)req);
|
398
|
+
} else if (UV_SUCCEEDED_WITH_IOCP(success)) {
|
399
|
+
handle->reqs_pending++;
|
400
|
+
} else {
|
401
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
402
|
+
return -1;
|
403
|
+
}
|
404
|
+
|
405
|
+
return 0;
|
406
|
+
}
|
407
|
+
|
408
|
+
|
409
|
+
static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
|
410
|
+
int bufcnt, struct sockaddr* addr, int addr_len, uv_udp_send_cb cb) {
|
411
|
+
uv_loop_t* loop = handle->loop;
|
412
|
+
DWORD result, bytes;
|
413
|
+
|
414
|
+
uv_req_init(loop, (uv_req_t*) req);
|
415
|
+
req->type = UV_UDP_SEND;
|
416
|
+
req->handle = handle;
|
417
|
+
req->cb = cb;
|
418
|
+
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
419
|
+
|
420
|
+
result = WSASendTo(handle->socket,
|
421
|
+
(WSABUF*)bufs,
|
422
|
+
bufcnt,
|
423
|
+
&bytes,
|
424
|
+
0,
|
425
|
+
addr,
|
426
|
+
addr_len,
|
427
|
+
&req->overlapped,
|
428
|
+
NULL);
|
429
|
+
|
430
|
+
if (UV_SUCCEEDED_WITHOUT_IOCP(result == 0)) {
|
431
|
+
/* Request completed immediately. */
|
432
|
+
req->queued_bytes = 0;
|
433
|
+
handle->reqs_pending++;
|
434
|
+
uv_insert_pending_req(loop, (uv_req_t*)req);
|
435
|
+
} else if (UV_SUCCEEDED_WITH_IOCP(result == 0)) {
|
436
|
+
/* Request queued by the kernel. */
|
437
|
+
req->queued_bytes = uv_count_bufs(bufs, bufcnt);
|
438
|
+
handle->reqs_pending++;
|
439
|
+
} else {
|
440
|
+
/* Send failed due to an error. */
|
441
|
+
uv_set_sys_error(loop, WSAGetLastError());
|
442
|
+
return -1;
|
443
|
+
}
|
444
|
+
|
445
|
+
return 0;
|
446
|
+
}
|
447
|
+
|
448
|
+
|
449
|
+
int uv_udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
|
450
|
+
int bufcnt, struct sockaddr_in addr, uv_udp_send_cb cb) {
|
451
|
+
|
452
|
+
if (!(handle->flags & UV_HANDLE_BOUND) &&
|
453
|
+
uv_udp_bind(handle, uv_addr_ip4_any_, 0) < 0) {
|
454
|
+
return -1;
|
455
|
+
}
|
456
|
+
|
457
|
+
return uv__udp_send(req,
|
458
|
+
handle,
|
459
|
+
bufs,
|
460
|
+
bufcnt,
|
461
|
+
(struct sockaddr*) &addr,
|
462
|
+
sizeof addr,
|
463
|
+
cb);
|
464
|
+
}
|
465
|
+
|
466
|
+
|
467
|
+
int uv_udp_send6(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
|
468
|
+
int bufcnt, struct sockaddr_in6 addr, uv_udp_send_cb cb) {
|
469
|
+
|
470
|
+
if (!(handle->flags & UV_HANDLE_BOUND) &&
|
471
|
+
uv_udp_bind6(handle, uv_addr_ip6_any_, 0) < 0) {
|
472
|
+
return -1;
|
473
|
+
}
|
474
|
+
|
475
|
+
return uv__udp_send(req,
|
476
|
+
handle,
|
477
|
+
bufs,
|
478
|
+
bufcnt,
|
479
|
+
(struct sockaddr*) &addr,
|
480
|
+
sizeof addr,
|
481
|
+
cb);
|
482
|
+
}
|
483
|
+
|
484
|
+
|
485
|
+
void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
|
486
|
+
uv_req_t* req) {
|
487
|
+
uv_buf_t buf;
|
488
|
+
int partial;
|
489
|
+
|
490
|
+
assert(handle->type == UV_UDP);
|
491
|
+
|
492
|
+
handle->flags &= ~UV_HANDLE_READ_PENDING;
|
493
|
+
|
494
|
+
if (!REQ_SUCCESS(req) &&
|
495
|
+
GET_REQ_STATUS(req) != STATUS_RECEIVE_EXPEDITED) {
|
496
|
+
/* An error occurred doing the read. */
|
497
|
+
if ((handle->flags & UV_HANDLE_READING)) {
|
498
|
+
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
499
|
+
uv_udp_recv_stop(handle);
|
500
|
+
#if 0
|
501
|
+
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
|
502
|
+
uv_buf_init(NULL, 0) : handle->recv_buffer;
|
503
|
+
#else
|
504
|
+
buf = handle->recv_buffer;
|
505
|
+
#endif
|
506
|
+
handle->recv_cb(handle, -1, buf, NULL, 0);
|
507
|
+
}
|
508
|
+
goto done;
|
509
|
+
}
|
510
|
+
|
511
|
+
#if 0
|
512
|
+
if (!(handle->flags & UV_HANDLE_ZERO_READ)) {
|
513
|
+
#endif
|
514
|
+
/* Successful read */
|
515
|
+
partial = (GET_REQ_STATUS(req) == STATUS_RECEIVE_EXPEDITED);
|
516
|
+
handle->recv_cb(handle,
|
517
|
+
req->overlapped.InternalHigh,
|
518
|
+
handle->recv_buffer,
|
519
|
+
(struct sockaddr*) &handle->recv_from,
|
520
|
+
partial ? UV_UDP_PARTIAL : 0);
|
521
|
+
#if 0
|
522
|
+
} else {
|
523
|
+
DWORD bytes, err, flags;
|
524
|
+
struct sockaddr_storage from;
|
525
|
+
int from_len;
|
526
|
+
|
527
|
+
/* Do a nonblocking receive */
|
528
|
+
/* TODO: try to read multiple datagrams at once. FIONREAD maybe? */
|
529
|
+
buf = handle->alloc_cb((uv_handle_t*) handle, 65536);
|
530
|
+
assert(buf.len > 0);
|
531
|
+
|
532
|
+
memset(&from, 0, sizeof from);
|
533
|
+
from_len = sizeof from;
|
534
|
+
flags = MSG_PARTIAL;
|
535
|
+
|
536
|
+
if (WSARecvFrom(handle->socket,
|
537
|
+
(WSABUF*)&buf,
|
538
|
+
1,
|
539
|
+
&bytes,
|
540
|
+
&flags,
|
541
|
+
(struct sockaddr*) &from,
|
542
|
+
&from_len,
|
543
|
+
NULL,
|
544
|
+
NULL) != SOCKET_ERROR) {
|
545
|
+
|
546
|
+
/* Message received */
|
547
|
+
handle->recv_cb(handle,
|
548
|
+
bytes,
|
549
|
+
buf,
|
550
|
+
(struct sockaddr*) &from,
|
551
|
+
(flags & MSG_PARTIAL) ? UV_UDP_PARTIAL : 0);
|
552
|
+
} else {
|
553
|
+
err = WSAGetLastError();
|
554
|
+
if (err == WSAEWOULDBLOCK) {
|
555
|
+
uv_set_sys_error(loop, WSAEWOULDBLOCK);
|
556
|
+
handle->recv_cb(handle, 0, buf, NULL, 0);
|
557
|
+
} else {
|
558
|
+
/* Ouch! serious error. */
|
559
|
+
uv_set_sys_error(loop, err);
|
560
|
+
handle->recv_cb(handle, -1, buf, NULL, 0);
|
561
|
+
}
|
562
|
+
}
|
563
|
+
}
|
564
|
+
#endif
|
565
|
+
|
566
|
+
done:
|
567
|
+
/* Post another read if still reading and not closing. */
|
568
|
+
if ((handle->flags & UV_HANDLE_READING) &&
|
569
|
+
!(handle->flags & UV_HANDLE_READ_PENDING)) {
|
570
|
+
uv_udp_queue_recv(loop, handle);
|
571
|
+
}
|
572
|
+
|
573
|
+
DECREASE_PENDING_REQ_COUNT(handle);
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
void uv_process_udp_send_req(uv_loop_t* loop, uv_udp_t* handle,
|
578
|
+
uv_udp_send_t* req) {
|
579
|
+
assert(handle->type == UV_UDP);
|
580
|
+
|
581
|
+
if (req->cb) {
|
582
|
+
if (REQ_SUCCESS(req)) {
|
583
|
+
req->cb(req, 0);
|
584
|
+
} else {
|
585
|
+
loop->last_error = GET_REQ_UV_SOCK_ERROR(req);
|
586
|
+
req->cb(req, -1);
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
DECREASE_PENDING_REQ_COUNT(handle);
|
591
|
+
}
|
592
|
+
|
@@ -27,13 +27,27 @@
|
|
27
27
|
#include "internal.h"
|
28
28
|
|
29
29
|
|
30
|
-
int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
|
31
|
-
|
30
|
+
int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
|
31
|
+
char* utf8Buffer, size_t utf8Size) {
|
32
|
+
return WideCharToMultiByte(CP_UTF8,
|
33
|
+
0,
|
34
|
+
utf16Buffer,
|
35
|
+
utf16Size,
|
36
|
+
utf8Buffer,
|
37
|
+
utf8Size,
|
38
|
+
NULL,
|
39
|
+
NULL);
|
32
40
|
}
|
33
41
|
|
34
42
|
|
35
|
-
int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer,
|
36
|
-
|
43
|
+
int uv_utf8_to_utf16(const char* utf8Buffer, wchar_t* utf16Buffer,
|
44
|
+
size_t utf16Size) {
|
45
|
+
return MultiByteToWideChar(CP_UTF8,
|
46
|
+
0,
|
47
|
+
utf8Buffer,
|
48
|
+
-1,
|
49
|
+
utf16Buffer,
|
50
|
+
utf16Size);
|
37
51
|
}
|
38
52
|
|
39
53
|
|
@@ -55,7 +69,7 @@ int uv_exepath(char* buffer, size_t* size) {
|
|
55
69
|
/* Get the path as UTF-16 */
|
56
70
|
utf16Size = GetModuleFileNameW(NULL, utf16Buffer, *size - 1);
|
57
71
|
if (utf16Size <= 0) {
|
58
|
-
uv_set_sys_error(GetLastError());
|
72
|
+
/* uv_set_sys_error(loop, GetLastError()); */
|
59
73
|
retVal = -1;
|
60
74
|
goto done;
|
61
75
|
}
|
@@ -65,7 +79,7 @@ int uv_exepath(char* buffer, size_t* size) {
|
|
65
79
|
/* Convert to UTF-8 */
|
66
80
|
*size = uv_utf16_to_utf8(utf16Buffer, utf16Size, buffer, *size);
|
67
81
|
if (!*size) {
|
68
|
-
uv_set_sys_error(GetLastError());
|
82
|
+
/* uv_set_sys_error(loop, GetLastError()); */
|
69
83
|
retVal = -1;
|
70
84
|
goto done;
|
71
85
|
}
|
@@ -28,25 +28,42 @@
|
|
28
28
|
|
29
29
|
sRtlNtStatusToDosError pRtlNtStatusToDosError;
|
30
30
|
sNtQueryInformationFile pNtQueryInformationFile;
|
31
|
+
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
|
32
|
+
sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
|
31
33
|
|
32
34
|
|
33
35
|
void uv_winapi_init() {
|
34
|
-
HMODULE
|
36
|
+
HMODULE ntdll_module;
|
37
|
+
HMODULE kernel32_module;
|
35
38
|
|
36
|
-
|
37
|
-
if (
|
39
|
+
ntdll_module = GetModuleHandleA("ntdll.dll");
|
40
|
+
if (ntdll_module == NULL) {
|
38
41
|
uv_fatal_error(GetLastError(), "GetModuleHandleA");
|
39
42
|
}
|
40
43
|
|
41
|
-
pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress(
|
44
|
+
pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress(
|
45
|
+
ntdll_module,
|
42
46
|
"RtlNtStatusToDosError");
|
43
47
|
if (pRtlNtStatusToDosError == NULL) {
|
44
48
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
45
49
|
}
|
46
50
|
|
47
|
-
pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress(
|
51
|
+
pNtQueryInformationFile = (sNtQueryInformationFile) GetProcAddress(
|
52
|
+
ntdll_module,
|
48
53
|
"NtQueryInformationFile");
|
49
54
|
if (pNtQueryInformationFile == NULL) {
|
50
55
|
uv_fatal_error(GetLastError(), "GetProcAddress");
|
51
56
|
}
|
52
|
-
|
57
|
+
|
58
|
+
kernel32_module = GetModuleHandleA("kernel32.dll");
|
59
|
+
if (kernel32_module == NULL) {
|
60
|
+
uv_fatal_error(GetLastError(), "GetModuleHandleA");
|
61
|
+
}
|
62
|
+
|
63
|
+
pGetQueuedCompletionStatusEx = (sGetQueuedCompletionStatusEx) GetProcAddress(
|
64
|
+
kernel32_module,
|
65
|
+
"GetQueuedCompletionStatusEx");
|
66
|
+
|
67
|
+
pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes)
|
68
|
+
GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes");
|
69
|
+
}
|