noderb 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -31,29 +31,43 @@
|
|
|
31
31
|
/* A zero-size buffer for use by uv_pipe_read */
|
|
32
32
|
static char uv_zero_[] = "";
|
|
33
33
|
|
|
34
|
+
/* Null uv_buf_t */
|
|
35
|
+
static const uv_buf_t uv_null_buf_ = { 0, NULL };
|
|
36
|
+
|
|
37
|
+
/* The timeout that the pipe will wait for the remote end to write data */
|
|
38
|
+
/* when the local ends wants to shut it down. */
|
|
39
|
+
static const int64_t eof_timeout = 50; /* ms */
|
|
40
|
+
|
|
41
|
+
static void eof_timer_init(uv_pipe_t* pipe);
|
|
42
|
+
static void eof_timer_start(uv_pipe_t* pipe);
|
|
43
|
+
static void eof_timer_stop(uv_pipe_t* pipe);
|
|
44
|
+
static void eof_timer_cb(uv_timer_t* timer, int status);
|
|
45
|
+
static void eof_timer_destroy(uv_pipe_t* pipe);
|
|
46
|
+
static void eof_timer_close_cb(uv_handle_t* handle);
|
|
47
|
+
|
|
34
48
|
|
|
35
49
|
static void uv_unique_pipe_name(char* ptr, char* name, size_t size) {
|
|
36
50
|
_snprintf(name, size, "\\\\.\\pipe\\uv\\%p-%d", ptr, GetCurrentProcessId());
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
|
|
40
|
-
int uv_pipe_init(uv_pipe_t* handle) {
|
|
41
|
-
uv_stream_init((uv_stream_t*)handle);
|
|
54
|
+
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle) {
|
|
55
|
+
uv_stream_init(loop, (uv_stream_t*)handle);
|
|
42
56
|
|
|
43
57
|
handle->type = UV_NAMED_PIPE;
|
|
44
58
|
handle->reqs_pending = 0;
|
|
45
|
-
handle->pending_accepts = NULL;
|
|
46
|
-
handle->name = NULL;
|
|
47
59
|
handle->handle = INVALID_HANDLE_VALUE;
|
|
60
|
+
handle->name = NULL;
|
|
48
61
|
|
|
49
|
-
|
|
62
|
+
loop->counters.pipe_init++;
|
|
50
63
|
|
|
51
64
|
return 0;
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
|
|
55
|
-
int uv_pipe_init_with_handle(uv_pipe_t* handle,
|
|
56
|
-
|
|
68
|
+
int uv_pipe_init_with_handle(uv_loop_t* loop, uv_pipe_t* handle,
|
|
69
|
+
HANDLE pipeHandle) {
|
|
70
|
+
int err = uv_pipe_init(loop, handle);
|
|
57
71
|
|
|
58
72
|
if (!err) {
|
|
59
73
|
/*
|
|
@@ -69,7 +83,14 @@ int uv_pipe_init_with_handle(uv_pipe_t* handle, HANDLE pipeHandle) {
|
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
|
|
72
|
-
|
|
86
|
+
static void uv_pipe_connection_init(uv_pipe_t* handle) {
|
|
87
|
+
uv_connection_init((uv_stream_t*) handle);
|
|
88
|
+
handle->eof_timer = NULL;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
|
|
93
|
+
char* name, size_t nameSize) {
|
|
73
94
|
HANDLE pipeHandle;
|
|
74
95
|
int errno;
|
|
75
96
|
int err;
|
|
@@ -79,13 +100,9 @@ int uv_stdio_pipe_server(uv_pipe_t* handle, DWORD access, char* name, size_t nam
|
|
|
79
100
|
uv_unique_pipe_name(ptr, name, nameSize);
|
|
80
101
|
|
|
81
102
|
pipeHandle = CreateNamedPipeA(name,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
65536,
|
|
86
|
-
65536,
|
|
87
|
-
0,
|
|
88
|
-
NULL);
|
|
103
|
+
access | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
|
|
104
|
+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 65536, 65536, 0,
|
|
105
|
+
NULL);
|
|
89
106
|
|
|
90
107
|
if (pipeHandle != INVALID_HANDLE_VALUE) {
|
|
91
108
|
/* No name collisions. We're done. */
|
|
@@ -94,7 +111,7 @@ int uv_stdio_pipe_server(uv_pipe_t* handle, DWORD access, char* name, size_t nam
|
|
|
94
111
|
|
|
95
112
|
errno = GetLastError();
|
|
96
113
|
if (errno != ERROR_PIPE_BUSY && errno != ERROR_ACCESS_DENIED) {
|
|
97
|
-
uv_set_sys_error(errno);
|
|
114
|
+
uv_set_sys_error(loop, errno);
|
|
98
115
|
err = -1;
|
|
99
116
|
goto done;
|
|
100
117
|
}
|
|
@@ -104,15 +121,15 @@ int uv_stdio_pipe_server(uv_pipe_t* handle, DWORD access, char* name, size_t nam
|
|
|
104
121
|
}
|
|
105
122
|
|
|
106
123
|
if (CreateIoCompletionPort(pipeHandle,
|
|
107
|
-
|
|
124
|
+
loop->iocp,
|
|
108
125
|
(ULONG_PTR)handle,
|
|
109
126
|
0) == NULL) {
|
|
110
|
-
uv_set_sys_error(GetLastError());
|
|
127
|
+
uv_set_sys_error(loop, GetLastError());
|
|
111
128
|
err = -1;
|
|
112
129
|
goto done;
|
|
113
130
|
}
|
|
114
131
|
|
|
115
|
-
|
|
132
|
+
uv_pipe_connection_init(handle);
|
|
116
133
|
handle->handle = pipeHandle;
|
|
117
134
|
handle->flags |= UV_HANDLE_GIVEN_OS_HANDLE;
|
|
118
135
|
err = 0;
|
|
@@ -126,7 +143,8 @@ done:
|
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
|
|
129
|
-
static int uv_set_pipe_handle(uv_pipe_t* handle,
|
|
146
|
+
static int uv_set_pipe_handle(uv_loop_t* loop, uv_pipe_t* handle,
|
|
147
|
+
HANDLE pipeHandle) {
|
|
130
148
|
DWORD mode = PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT;
|
|
131
149
|
|
|
132
150
|
if (!SetNamedPipeHandleState(pipeHandle, &mode, NULL, NULL)) {
|
|
@@ -134,7 +152,7 @@ static int uv_set_pipe_handle(uv_pipe_t* handle, HANDLE pipeHandle) {
|
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
if (CreateIoCompletionPort(pipeHandle,
|
|
137
|
-
|
|
155
|
+
loop->iocp,
|
|
138
156
|
(ULONG_PTR)handle,
|
|
139
157
|
0) == NULL) {
|
|
140
158
|
return -1;
|
|
@@ -146,6 +164,7 @@ static int uv_set_pipe_handle(uv_pipe_t* handle, HANDLE pipeHandle) {
|
|
|
146
164
|
|
|
147
165
|
static DWORD WINAPI pipe_shutdown_thread_proc(void* parameter) {
|
|
148
166
|
int errno;
|
|
167
|
+
uv_loop_t* loop;
|
|
149
168
|
uv_pipe_t* handle;
|
|
150
169
|
uv_shutdown_t* req;
|
|
151
170
|
|
|
@@ -153,24 +172,19 @@ static DWORD WINAPI pipe_shutdown_thread_proc(void* parameter) {
|
|
|
153
172
|
assert(req);
|
|
154
173
|
handle = (uv_pipe_t*) req->handle;
|
|
155
174
|
assert(handle);
|
|
175
|
+
loop = handle->loop;
|
|
176
|
+
assert(loop);
|
|
156
177
|
|
|
157
178
|
FlushFileBuffers(handle->handle);
|
|
158
179
|
|
|
159
180
|
/* Post completed */
|
|
160
|
-
|
|
161
|
-
0,
|
|
162
|
-
0,
|
|
163
|
-
&req->overlapped)) {
|
|
164
|
-
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus");
|
|
165
|
-
}
|
|
181
|
+
POST_COMPLETION_FOR_REQ(loop, req);
|
|
166
182
|
|
|
167
183
|
return 0;
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
|
|
171
|
-
void uv_pipe_endgame(uv_pipe_t* handle) {
|
|
172
|
-
uv_err_t err;
|
|
173
|
-
int status;
|
|
187
|
+
void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
|
|
174
188
|
unsigned int uv_alloced;
|
|
175
189
|
DWORD result;
|
|
176
190
|
uv_shutdown_t* req;
|
|
@@ -195,7 +209,7 @@ void uv_pipe_endgame(uv_pipe_t* handle) {
|
|
|
195
209
|
/* Failure */
|
|
196
210
|
handle->flags &= ~UV_HANDLE_SHUTTING;
|
|
197
211
|
if (req->cb) {
|
|
198
|
-
uv_set_sys_error(pRtlNtStatusToDosError(nt_status));
|
|
212
|
+
uv_set_sys_error(loop, pRtlNtStatusToDosError(nt_status));
|
|
199
213
|
req->cb(req, -1);
|
|
200
214
|
}
|
|
201
215
|
DECREASE_PENDING_REQ_COUNT(handle);
|
|
@@ -203,12 +217,10 @@ void uv_pipe_endgame(uv_pipe_t* handle) {
|
|
|
203
217
|
}
|
|
204
218
|
|
|
205
219
|
if (pipe_info.OutboundQuota == pipe_info.WriteQuotaAvailable) {
|
|
206
|
-
/* Short-circuit, no need to call FlushFileBuffers. */
|
|
207
220
|
handle->flags |= UV_HANDLE_SHUT;
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
DECREASE_PENDING_REQ_COUNT(handle);
|
|
221
|
+
|
|
222
|
+
/* Short-circuit, no need to call FlushFileBuffers. */
|
|
223
|
+
uv_insert_pending_req(loop, (uv_req_t*) req);
|
|
212
224
|
return;
|
|
213
225
|
}
|
|
214
226
|
|
|
@@ -224,7 +236,7 @@ void uv_pipe_endgame(uv_pipe_t* handle) {
|
|
|
224
236
|
/* Failure. */
|
|
225
237
|
handle->flags &= ~UV_HANDLE_SHUTTING;
|
|
226
238
|
if (req->cb) {
|
|
227
|
-
uv_set_sys_error(GetLastError());
|
|
239
|
+
uv_set_sys_error(loop, GetLastError());
|
|
228
240
|
req->cb(req, -1);
|
|
229
241
|
}
|
|
230
242
|
DECREASE_PENDING_REQ_COUNT(handle);
|
|
@@ -249,29 +261,30 @@ void uv_pipe_endgame(uv_pipe_t* handle) {
|
|
|
249
261
|
free(handle);
|
|
250
262
|
}
|
|
251
263
|
|
|
252
|
-
uv_unref();
|
|
264
|
+
uv_unref(loop);
|
|
253
265
|
}
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
|
|
257
269
|
/* Creates a pipe server. */
|
|
258
270
|
int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|
|
271
|
+
uv_loop_t* loop = handle->loop;
|
|
259
272
|
int i, errno, nameSize;
|
|
260
273
|
uv_pipe_accept_t* req;
|
|
261
274
|
|
|
262
275
|
if (handle->flags & UV_HANDLE_BOUND) {
|
|
263
|
-
uv_set_sys_error(WSAEINVAL);
|
|
276
|
+
uv_set_sys_error(loop, WSAEINVAL);
|
|
264
277
|
return -1;
|
|
265
278
|
}
|
|
266
279
|
|
|
267
280
|
if (!name) {
|
|
268
|
-
uv_set_sys_error(WSAEINVAL);
|
|
281
|
+
uv_set_sys_error(loop, WSAEINVAL);
|
|
269
282
|
return -1;
|
|
270
283
|
}
|
|
271
284
|
|
|
272
285
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) {
|
|
273
286
|
req = &handle->accept_reqs[i];
|
|
274
|
-
uv_req_init((uv_req_t*) req);
|
|
287
|
+
uv_req_init(loop, (uv_req_t*) req);
|
|
275
288
|
req->type = UV_ACCEPT;
|
|
276
289
|
req->data = handle;
|
|
277
290
|
req->pipeHandle = INVALID_HANDLE_VALUE;
|
|
@@ -286,7 +299,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|
|
|
286
299
|
}
|
|
287
300
|
|
|
288
301
|
if (!uv_utf8_to_utf16(name, handle->name, nameSize / sizeof(wchar_t))) {
|
|
289
|
-
uv_set_sys_error(GetLastError());
|
|
302
|
+
uv_set_sys_error(loop, GetLastError());
|
|
290
303
|
return -1;
|
|
291
304
|
}
|
|
292
305
|
|
|
@@ -295,33 +308,29 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
|
|
|
295
308
|
* If this fails then there's already a pipe server for the given pipe name.
|
|
296
309
|
*/
|
|
297
310
|
handle->accept_reqs[0].pipeHandle = CreateNamedPipeW(handle->name,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
65536,
|
|
303
|
-
0,
|
|
304
|
-
NULL);
|
|
311
|
+
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
|
|
312
|
+
FILE_FLAG_FIRST_PIPE_INSTANCE,
|
|
313
|
+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
|
|
314
|
+
PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL);
|
|
305
315
|
|
|
306
316
|
if (handle->accept_reqs[0].pipeHandle == INVALID_HANDLE_VALUE) {
|
|
307
317
|
errno = GetLastError();
|
|
308
318
|
if (errno == ERROR_ACCESS_DENIED) {
|
|
309
|
-
uv_set_error(UV_EADDRINUSE, errno);
|
|
310
|
-
handle->error = LOOP->last_error;
|
|
311
|
-
handle->flags |= UV_HANDLE_BIND_ERROR;
|
|
319
|
+
uv_set_error(loop, UV_EADDRINUSE, errno);
|
|
312
320
|
} else if (errno == ERROR_PATH_NOT_FOUND || errno == ERROR_INVALID_NAME) {
|
|
313
|
-
uv_set_error(UV_EACCESS, errno);
|
|
321
|
+
uv_set_error(loop, UV_EACCESS, errno);
|
|
314
322
|
} else {
|
|
315
|
-
uv_set_sys_error(errno);
|
|
323
|
+
uv_set_sys_error(loop, errno);
|
|
316
324
|
}
|
|
317
325
|
goto error;
|
|
318
326
|
}
|
|
319
327
|
|
|
320
|
-
if (uv_set_pipe_handle(handle, handle->accept_reqs[0].pipeHandle)) {
|
|
321
|
-
uv_set_sys_error(GetLastError());
|
|
328
|
+
if (uv_set_pipe_handle(loop, handle, handle->accept_reqs[0].pipeHandle)) {
|
|
329
|
+
uv_set_sys_error(loop, GetLastError());
|
|
322
330
|
goto error;
|
|
323
331
|
}
|
|
324
332
|
|
|
333
|
+
handle->pending_accepts = NULL;
|
|
325
334
|
handle->flags |= UV_HANDLE_PIPESERVER;
|
|
326
335
|
handle->flags |= UV_HANDLE_BOUND;
|
|
327
336
|
|
|
@@ -345,15 +354,19 @@ error:
|
|
|
345
354
|
static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
|
|
346
355
|
HANDLE pipeHandle = INVALID_HANDLE_VALUE;
|
|
347
356
|
int errno;
|
|
357
|
+
uv_loop_t* loop;
|
|
348
358
|
uv_pipe_t* handle;
|
|
349
359
|
uv_connect_t* req;
|
|
350
360
|
|
|
351
|
-
req = (uv_connect_t*)parameter;
|
|
361
|
+
req = (uv_connect_t*) parameter;
|
|
352
362
|
assert(req);
|
|
353
|
-
handle = (uv_pipe_t*)req->handle;
|
|
363
|
+
handle = (uv_pipe_t*) req->handle;
|
|
354
364
|
assert(handle);
|
|
365
|
+
loop = handle->loop;
|
|
366
|
+
assert(loop);
|
|
355
367
|
|
|
356
|
-
/* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY.
|
|
368
|
+
/* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */
|
|
369
|
+
/* We wait for the pipe to become available with WaitNamedPipe. */
|
|
357
370
|
while (WaitNamedPipeW(handle->name, 30000)) {
|
|
358
371
|
/* The pipe is now available, try to connect. */
|
|
359
372
|
pipeHandle = CreateFileW(handle->name,
|
|
@@ -371,22 +384,16 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
|
|
|
371
384
|
SwitchToThread();
|
|
372
385
|
}
|
|
373
386
|
|
|
374
|
-
if (pipeHandle != INVALID_HANDLE_VALUE &&
|
|
387
|
+
if (pipeHandle != INVALID_HANDLE_VALUE &&
|
|
388
|
+
!uv_set_pipe_handle(loop, handle, pipeHandle)) {
|
|
375
389
|
handle->handle = pipeHandle;
|
|
376
|
-
req
|
|
390
|
+
SET_REQ_SUCCESS(req);
|
|
377
391
|
} else {
|
|
378
|
-
req
|
|
392
|
+
SET_REQ_ERROR(req, GetLastError());
|
|
379
393
|
}
|
|
380
394
|
|
|
381
|
-
memset(&req->overlapped, 0, sizeof(req->overlapped));
|
|
382
|
-
|
|
383
395
|
/* Post completed */
|
|
384
|
-
|
|
385
|
-
0,
|
|
386
|
-
0,
|
|
387
|
-
&req->overlapped)) {
|
|
388
|
-
uv_fatal_error(GetLastError(), "PostQueuedCompletionStatus");
|
|
389
|
-
}
|
|
396
|
+
POST_COMPLETION_FOR_REQ(loop, req);
|
|
390
397
|
|
|
391
398
|
return 0;
|
|
392
399
|
}
|
|
@@ -394,12 +401,13 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
|
|
|
394
401
|
|
|
395
402
|
int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
|
396
403
|
const char* name, uv_connect_cb cb) {
|
|
404
|
+
uv_loop_t* loop = handle->loop;
|
|
397
405
|
int errno, nameSize;
|
|
398
406
|
HANDLE pipeHandle;
|
|
399
407
|
|
|
400
408
|
handle->handle = INVALID_HANDLE_VALUE;
|
|
401
409
|
|
|
402
|
-
uv_req_init((uv_req_t*) req);
|
|
410
|
+
uv_req_init(loop, (uv_req_t*) req);
|
|
403
411
|
req->type = UV_CONNECT;
|
|
404
412
|
req->handle = (uv_stream_t*) handle;
|
|
405
413
|
req->cb = cb;
|
|
@@ -427,7 +435,9 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
|
|
427
435
|
if (pipeHandle == INVALID_HANDLE_VALUE) {
|
|
428
436
|
if (GetLastError() == ERROR_PIPE_BUSY) {
|
|
429
437
|
/* Wait for the server to make a pipe instance available. */
|
|
430
|
-
if (!QueueUserWorkItem(&pipe_connect_thread_proc,
|
|
438
|
+
if (!QueueUserWorkItem(&pipe_connect_thread_proc,
|
|
439
|
+
req,
|
|
440
|
+
WT_EXECUTELONGFUNCTION)) {
|
|
431
441
|
errno = GetLastError();
|
|
432
442
|
goto error;
|
|
433
443
|
}
|
|
@@ -441,15 +451,15 @@ int uv_pipe_connect(uv_connect_t* req, uv_pipe_t* handle,
|
|
|
441
451
|
goto error;
|
|
442
452
|
}
|
|
443
453
|
|
|
444
|
-
if (uv_set_pipe_handle((uv_pipe_t*)req->handle, pipeHandle)) {
|
|
454
|
+
if (uv_set_pipe_handle(loop, (uv_pipe_t*)req->handle, pipeHandle)) {
|
|
445
455
|
errno = GetLastError();
|
|
446
456
|
goto error;
|
|
447
457
|
}
|
|
448
458
|
|
|
449
459
|
handle->handle = pipeHandle;
|
|
450
460
|
|
|
451
|
-
req
|
|
452
|
-
uv_insert_pending_req((uv_req_t*) req);
|
|
461
|
+
SET_REQ_SUCCESS(req);
|
|
462
|
+
uv_insert_pending_req(loop, (uv_req_t*) req);
|
|
453
463
|
handle->reqs_pending++;
|
|
454
464
|
return 0;
|
|
455
465
|
|
|
@@ -462,12 +472,13 @@ error:
|
|
|
462
472
|
if (pipeHandle != INVALID_HANDLE_VALUE) {
|
|
463
473
|
CloseHandle(pipeHandle);
|
|
464
474
|
}
|
|
465
|
-
uv_set_sys_error(errno);
|
|
475
|
+
uv_set_sys_error(loop, errno);
|
|
466
476
|
return -1;
|
|
467
477
|
}
|
|
468
478
|
|
|
469
479
|
|
|
470
|
-
/* Cleans up uv_pipe_t (server or connection) and all resources associated
|
|
480
|
+
/* Cleans up uv_pipe_t (server or connection) and all resources associated */
|
|
481
|
+
/* with it. */
|
|
471
482
|
void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) {
|
|
472
483
|
int i;
|
|
473
484
|
HANDLE pipeHandle;
|
|
@@ -486,7 +497,14 @@ void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) {
|
|
|
486
497
|
}
|
|
487
498
|
}
|
|
488
499
|
|
|
489
|
-
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (handle->flags & UV_HANDLE_CONNECTION) {
|
|
503
|
+
eof_timer_destroy(handle);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
if ((handle->flags & UV_HANDLE_CONNECTION)
|
|
507
|
+
&& handle->handle != INVALID_HANDLE_VALUE) {
|
|
490
508
|
CloseHandle(handle->handle);
|
|
491
509
|
handle->handle = INVALID_HANDLE_VALUE;
|
|
492
510
|
}
|
|
@@ -495,33 +513,30 @@ void close_pipe(uv_pipe_t* handle, int* status, uv_err_t* err) {
|
|
|
495
513
|
}
|
|
496
514
|
|
|
497
515
|
|
|
498
|
-
static void uv_pipe_queue_accept(
|
|
516
|
+
static void uv_pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle,
|
|
517
|
+
uv_pipe_accept_t* req, BOOL firstInstance) {
|
|
499
518
|
assert(handle->flags & UV_HANDLE_LISTENING);
|
|
500
519
|
|
|
501
520
|
if (!firstInstance) {
|
|
502
521
|
assert(req->pipeHandle == INVALID_HANDLE_VALUE);
|
|
503
522
|
|
|
504
523
|
req->pipeHandle = CreateNamedPipeW(handle->name,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
65536,
|
|
509
|
-
65536,
|
|
510
|
-
0,
|
|
511
|
-
NULL);
|
|
524
|
+
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
|
525
|
+
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
|
|
526
|
+
PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL);
|
|
512
527
|
|
|
513
528
|
if (req->pipeHandle == INVALID_HANDLE_VALUE) {
|
|
514
|
-
req
|
|
515
|
-
uv_insert_pending_req((uv_req_t*) req);
|
|
529
|
+
SET_REQ_ERROR(req, GetLastError());
|
|
530
|
+
uv_insert_pending_req(loop, (uv_req_t*) req);
|
|
516
531
|
handle->reqs_pending++;
|
|
517
532
|
return;
|
|
518
533
|
}
|
|
519
534
|
|
|
520
|
-
if (uv_set_pipe_handle(handle, req->pipeHandle)) {
|
|
535
|
+
if (uv_set_pipe_handle(loop, handle, req->pipeHandle)) {
|
|
521
536
|
CloseHandle(req->pipeHandle);
|
|
522
537
|
req->pipeHandle = INVALID_HANDLE_VALUE;
|
|
523
|
-
req
|
|
524
|
-
uv_insert_pending_req((uv_req_t*) req);
|
|
538
|
+
SET_REQ_ERROR(req, GetLastError());
|
|
539
|
+
uv_insert_pending_req(loop, (uv_req_t*) req);
|
|
525
540
|
handle->reqs_pending++;
|
|
526
541
|
return;
|
|
527
542
|
}
|
|
@@ -532,16 +547,17 @@ static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req, BOOL
|
|
|
532
547
|
/* Prepare the overlapped structure. */
|
|
533
548
|
memset(&(req->overlapped), 0, sizeof(req->overlapped));
|
|
534
549
|
|
|
535
|
-
if (!ConnectNamedPipe(req->pipeHandle, &req->overlapped) &&
|
|
550
|
+
if (!ConnectNamedPipe(req->pipeHandle, &req->overlapped) &&
|
|
551
|
+
GetLastError() != ERROR_IO_PENDING) {
|
|
536
552
|
if (GetLastError() == ERROR_PIPE_CONNECTED) {
|
|
537
|
-
req
|
|
553
|
+
SET_REQ_SUCCESS(req);
|
|
538
554
|
} else {
|
|
539
555
|
CloseHandle(req->pipeHandle);
|
|
540
556
|
req->pipeHandle = INVALID_HANDLE_VALUE;
|
|
541
557
|
/* Make this req pending reporting an error. */
|
|
542
|
-
req
|
|
558
|
+
SET_REQ_ERROR(req, GetLastError());
|
|
543
559
|
}
|
|
544
|
-
uv_insert_pending_req((uv_req_t*) req);
|
|
560
|
+
uv_insert_pending_req(loop, (uv_req_t*) req);
|
|
545
561
|
handle->reqs_pending++;
|
|
546
562
|
return;
|
|
547
563
|
}
|
|
@@ -551,17 +567,19 @@ static void uv_pipe_queue_accept(uv_pipe_t* handle, uv_pipe_accept_t* req, BOOL
|
|
|
551
567
|
|
|
552
568
|
|
|
553
569
|
int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) {
|
|
554
|
-
|
|
570
|
+
uv_loop_t* loop = server->loop;
|
|
571
|
+
/* Find a connection instance that has been connected, but not yet */
|
|
572
|
+
/* accepted. */
|
|
555
573
|
uv_pipe_accept_t* req = server->pending_accepts;
|
|
556
574
|
|
|
557
575
|
if (!req) {
|
|
558
576
|
/* No valid connections found, so we error out. */
|
|
559
|
-
uv_set_sys_error(WSAEWOULDBLOCK);
|
|
577
|
+
uv_set_sys_error(loop, WSAEWOULDBLOCK);
|
|
560
578
|
return -1;
|
|
561
579
|
}
|
|
562
580
|
|
|
563
581
|
/* Initialize the client handle and copy the pipeHandle to the client */
|
|
564
|
-
|
|
582
|
+
uv_pipe_connection_init(client);
|
|
565
583
|
client->handle = req->pipeHandle;
|
|
566
584
|
|
|
567
585
|
/* Prepare the req to pick up a new connection */
|
|
@@ -571,7 +589,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) {
|
|
|
571
589
|
|
|
572
590
|
if (!(server->flags & UV_HANDLE_CLOSING) &&
|
|
573
591
|
!(server->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
|
|
574
|
-
uv_pipe_queue_accept(server, req, FALSE);
|
|
592
|
+
uv_pipe_queue_accept(loop, server, req, FALSE);
|
|
575
593
|
}
|
|
576
594
|
|
|
577
595
|
return 0;
|
|
@@ -580,30 +598,27 @@ int uv_pipe_accept(uv_pipe_t* server, uv_pipe_t* client) {
|
|
|
580
598
|
|
|
581
599
|
/* Starts listening for connections for the given pipe. */
|
|
582
600
|
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
|
|
601
|
+
uv_loop_t* loop = handle->loop;
|
|
602
|
+
|
|
583
603
|
int i, errno;
|
|
584
604
|
uv_pipe_accept_t* req;
|
|
585
605
|
HANDLE pipeHandle;
|
|
586
606
|
|
|
587
|
-
if (handle->flags & UV_HANDLE_BIND_ERROR) {
|
|
588
|
-
uv_set_error(UV_EINVAL, 0);
|
|
589
|
-
return -1;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
607
|
if (!(handle->flags & UV_HANDLE_BOUND) &&
|
|
593
608
|
!(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
|
|
594
|
-
uv_set_error(UV_EINVAL, 0);
|
|
609
|
+
uv_set_error(loop, UV_EINVAL, 0);
|
|
595
610
|
return -1;
|
|
596
611
|
}
|
|
597
612
|
|
|
598
613
|
if (handle->flags & UV_HANDLE_LISTENING ||
|
|
599
614
|
handle->flags & UV_HANDLE_READING) {
|
|
600
|
-
uv_set_error(UV_EALREADY, 0);
|
|
615
|
+
uv_set_error(loop, UV_EALREADY, 0);
|
|
601
616
|
return -1;
|
|
602
617
|
}
|
|
603
618
|
|
|
604
619
|
if (!(handle->flags & UV_HANDLE_PIPESERVER) &&
|
|
605
620
|
!(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
|
|
606
|
-
uv_set_error(UV_ENOTSUP, 0);
|
|
621
|
+
uv_set_error(loop, UV_ENOTSUP, 0);
|
|
607
622
|
return -1;
|
|
608
623
|
}
|
|
609
624
|
|
|
@@ -615,24 +630,24 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
|
|
|
615
630
|
pipeHandle = handle->handle;
|
|
616
631
|
assert(pipeHandle != INVALID_HANDLE_VALUE);
|
|
617
632
|
req = &handle->accept_reqs[0];
|
|
618
|
-
uv_req_init((uv_req_t*) req);
|
|
633
|
+
uv_req_init(loop, (uv_req_t*) req);
|
|
619
634
|
req->pipeHandle = pipeHandle;
|
|
620
635
|
req->type = UV_ACCEPT;
|
|
621
636
|
req->data = handle;
|
|
622
637
|
req->next_pending = NULL;
|
|
623
638
|
|
|
624
|
-
if (uv_set_pipe_handle(handle, pipeHandle)) {
|
|
625
|
-
uv_set_sys_error(GetLastError());
|
|
639
|
+
if (uv_set_pipe_handle(loop, handle, pipeHandle)) {
|
|
640
|
+
uv_set_sys_error(loop, GetLastError());
|
|
626
641
|
return -1;
|
|
627
642
|
}
|
|
628
643
|
|
|
629
|
-
uv_pipe_queue_accept(handle, req, TRUE);
|
|
644
|
+
uv_pipe_queue_accept(loop, handle, req, TRUE);
|
|
630
645
|
} else {
|
|
631
646
|
/* First pipe handle should have already been created in uv_pipe_bind */
|
|
632
647
|
assert(handle->accept_reqs[0].pipeHandle != INVALID_HANDLE_VALUE);
|
|
633
648
|
|
|
634
649
|
for (i = 0; i < COUNTOF(handle->accept_reqs); i++) {
|
|
635
|
-
uv_pipe_queue_accept(handle, &handle->accept_reqs[i], i == 0);
|
|
650
|
+
uv_pipe_queue_accept(loop, handle, &handle->accept_reqs[i], i == 0);
|
|
636
651
|
}
|
|
637
652
|
}
|
|
638
653
|
|
|
@@ -640,7 +655,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
|
|
|
640
655
|
}
|
|
641
656
|
|
|
642
657
|
|
|
643
|
-
static void uv_pipe_queue_read(uv_pipe_t* handle) {
|
|
658
|
+
static void uv_pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) {
|
|
644
659
|
uv_req_t* req;
|
|
645
660
|
int result;
|
|
646
661
|
|
|
@@ -661,30 +676,36 @@ static void uv_pipe_queue_read(uv_pipe_t* handle) {
|
|
|
661
676
|
|
|
662
677
|
if (!result && GetLastError() != ERROR_IO_PENDING) {
|
|
663
678
|
/* Make this req pending reporting an error. */
|
|
664
|
-
req
|
|
665
|
-
uv_insert_pending_req(req);
|
|
679
|
+
SET_REQ_ERROR(req, WSAGetLastError());
|
|
680
|
+
uv_insert_pending_req(loop, req);
|
|
666
681
|
handle->reqs_pending++;
|
|
667
682
|
return;
|
|
668
683
|
}
|
|
669
684
|
|
|
685
|
+
/* Start the eof timer if there is one */
|
|
686
|
+
eof_timer_start(handle);
|
|
687
|
+
|
|
670
688
|
handle->flags |= UV_HANDLE_READ_PENDING;
|
|
671
689
|
handle->reqs_pending++;
|
|
672
690
|
}
|
|
673
691
|
|
|
674
692
|
|
|
675
|
-
int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
|
|
693
|
+
int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
|
|
694
|
+
uv_read_cb read_cb) {
|
|
695
|
+
uv_loop_t* loop = handle->loop;
|
|
696
|
+
|
|
676
697
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
|
|
677
|
-
uv_set_error(UV_EINVAL, 0);
|
|
698
|
+
uv_set_error(loop, UV_EINVAL, 0);
|
|
678
699
|
return -1;
|
|
679
700
|
}
|
|
680
701
|
|
|
681
702
|
if (handle->flags & UV_HANDLE_READING) {
|
|
682
|
-
uv_set_error(UV_EALREADY, 0);
|
|
703
|
+
uv_set_error(loop, UV_EALREADY, 0);
|
|
683
704
|
return -1;
|
|
684
705
|
}
|
|
685
706
|
|
|
686
707
|
if (handle->flags & UV_HANDLE_EOF) {
|
|
687
|
-
uv_set_error(UV_EOF, 0);
|
|
708
|
+
uv_set_error(loop, UV_EOF, 0);
|
|
688
709
|
return -1;
|
|
689
710
|
}
|
|
690
711
|
|
|
@@ -695,34 +716,34 @@ int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb, uv_read_cb read_
|
|
|
695
716
|
/* If reading was stopped and then started again, there could stell be a */
|
|
696
717
|
/* read request pending. */
|
|
697
718
|
if (!(handle->flags & UV_HANDLE_READ_PENDING))
|
|
698
|
-
uv_pipe_queue_read(handle);
|
|
719
|
+
uv_pipe_queue_read(loop, handle);
|
|
699
720
|
|
|
700
721
|
return 0;
|
|
701
722
|
}
|
|
702
723
|
|
|
703
724
|
|
|
704
|
-
int uv_pipe_write(uv_write_t* req, uv_pipe_t* handle,
|
|
705
|
-
uv_write_cb cb) {
|
|
725
|
+
int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
|
|
726
|
+
uv_buf_t bufs[], int bufcnt, uv_write_cb cb) {
|
|
706
727
|
int result;
|
|
707
728
|
|
|
708
729
|
if (bufcnt != 1) {
|
|
709
|
-
uv_set_error(UV_ENOTSUP, 0);
|
|
730
|
+
uv_set_error(loop, UV_ENOTSUP, 0);
|
|
710
731
|
return -1;
|
|
711
732
|
}
|
|
712
733
|
|
|
713
734
|
assert(handle->handle != INVALID_HANDLE_VALUE);
|
|
714
735
|
|
|
715
736
|
if (!(handle->flags & UV_HANDLE_CONNECTION)) {
|
|
716
|
-
uv_set_error(UV_EINVAL, 0);
|
|
737
|
+
uv_set_error(loop, UV_EINVAL, 0);
|
|
717
738
|
return -1;
|
|
718
739
|
}
|
|
719
740
|
|
|
720
741
|
if (handle->flags & UV_HANDLE_SHUTTING) {
|
|
721
|
-
uv_set_error(UV_EOF, 0);
|
|
742
|
+
uv_set_error(loop, UV_EOF, 0);
|
|
722
743
|
return -1;
|
|
723
744
|
}
|
|
724
745
|
|
|
725
|
-
uv_req_init((uv_req_t*) req);
|
|
746
|
+
uv_req_init(loop, (uv_req_t*) req);
|
|
726
747
|
req->type = UV_WRITE;
|
|
727
748
|
req->handle = (uv_stream_t*) handle;
|
|
728
749
|
req->cb = cb;
|
|
@@ -735,7 +756,7 @@ int uv_pipe_write(uv_write_t* req, uv_pipe_t* handle, uv_buf_t bufs[], int bufcn
|
|
|
735
756
|
&req->overlapped);
|
|
736
757
|
|
|
737
758
|
if (!result && GetLastError() != ERROR_IO_PENDING) {
|
|
738
|
-
uv_set_sys_error(GetLastError());
|
|
759
|
+
uv_set_sys_error(loop, GetLastError());
|
|
739
760
|
return -1;
|
|
740
761
|
}
|
|
741
762
|
|
|
@@ -755,23 +776,60 @@ int uv_pipe_write(uv_write_t* req, uv_pipe_t* handle, uv_buf_t bufs[], int bufcn
|
|
|
755
776
|
}
|
|
756
777
|
|
|
757
778
|
|
|
758
|
-
void
|
|
779
|
+
static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
|
|
780
|
+
uv_buf_t buf) {
|
|
781
|
+
/* If there is an eof timer running, we don't need it any more, */
|
|
782
|
+
/* so discard it. */
|
|
783
|
+
eof_timer_destroy(handle);
|
|
784
|
+
|
|
785
|
+
handle->flags |= UV_HANDLE_EOF;
|
|
786
|
+
uv_read_stop((uv_stream_t*) handle);
|
|
787
|
+
|
|
788
|
+
uv_set_error(loop, UV_EOF, 0);
|
|
789
|
+
handle->read_cb((uv_stream_t*) handle, -1, uv_null_buf_);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
|
|
794
|
+
uv_buf_t buf) {
|
|
795
|
+
/* If there is an eof timer running, we don't need it any more, */
|
|
796
|
+
/* so discard it. */
|
|
797
|
+
eof_timer_destroy(handle);
|
|
798
|
+
|
|
799
|
+
uv_read_stop((uv_stream_t*) handle);
|
|
800
|
+
|
|
801
|
+
uv_set_sys_error(loop, error);
|
|
802
|
+
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle,
|
|
807
|
+
int error, uv_buf_t buf) {
|
|
808
|
+
if (error == ERROR_BROKEN_PIPE) {
|
|
809
|
+
uv_pipe_read_eof(loop, handle, buf);
|
|
810
|
+
} else {
|
|
811
|
+
uv_pipe_read_error(loop, handle, error, buf);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
|
|
816
|
+
void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
|
|
817
|
+
uv_req_t* req) {
|
|
759
818
|
DWORD bytes, avail;
|
|
760
819
|
uv_buf_t buf;
|
|
761
820
|
|
|
762
821
|
assert(handle->type == UV_NAMED_PIPE);
|
|
763
822
|
|
|
764
823
|
handle->flags &= ~UV_HANDLE_READ_PENDING;
|
|
824
|
+
eof_timer_stop(handle);
|
|
765
825
|
|
|
766
|
-
if (req
|
|
826
|
+
if (!REQ_SUCCESS(req)) {
|
|
767
827
|
/* An error occurred doing the 0-read. */
|
|
768
828
|
if (handle->flags & UV_HANDLE_READING) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
buf.len = 0;
|
|
774
|
-
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
|
829
|
+
uv_pipe_read_error_or_eof(loop,
|
|
830
|
+
handle,
|
|
831
|
+
GET_REQ_ERROR(req),
|
|
832
|
+
uv_null_buf_);
|
|
775
833
|
}
|
|
776
834
|
} else {
|
|
777
835
|
/* Do non-blocking reads until the buffer is empty */
|
|
@@ -782,10 +840,7 @@ void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) {
|
|
|
782
840
|
NULL,
|
|
783
841
|
&avail,
|
|
784
842
|
NULL)) {
|
|
785
|
-
|
|
786
|
-
buf.base = 0;
|
|
787
|
-
buf.len = 0;
|
|
788
|
-
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
|
843
|
+
uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_);
|
|
789
844
|
break;
|
|
790
845
|
}
|
|
791
846
|
|
|
@@ -794,7 +849,7 @@ void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) {
|
|
|
794
849
|
break;
|
|
795
850
|
}
|
|
796
851
|
|
|
797
|
-
buf = handle->alloc_cb((
|
|
852
|
+
buf = handle->alloc_cb((uv_handle_t*) handle, avail);
|
|
798
853
|
assert(buf.len > 0);
|
|
799
854
|
|
|
800
855
|
if (ReadFile(handle->handle,
|
|
@@ -809,9 +864,7 @@ void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) {
|
|
|
809
864
|
break;
|
|
810
865
|
}
|
|
811
866
|
} else {
|
|
812
|
-
|
|
813
|
-
uv_set_sys_error(GetLastError());
|
|
814
|
-
handle->read_cb((uv_stream_t*)handle, -1, buf);
|
|
867
|
+
uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_);
|
|
815
868
|
break;
|
|
816
869
|
}
|
|
817
870
|
}
|
|
@@ -819,7 +872,7 @@ void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) {
|
|
|
819
872
|
/* Post another 0-read if still reading and not closing. */
|
|
820
873
|
if ((handle->flags & UV_HANDLE_READING) &&
|
|
821
874
|
!(handle->flags & UV_HANDLE_READ_PENDING)) {
|
|
822
|
-
uv_pipe_queue_read(handle);
|
|
875
|
+
uv_pipe_queue_read(loop, handle);
|
|
823
876
|
}
|
|
824
877
|
}
|
|
825
878
|
|
|
@@ -827,32 +880,38 @@ void uv_process_pipe_read_req(uv_pipe_t* handle, uv_req_t* req) {
|
|
|
827
880
|
}
|
|
828
881
|
|
|
829
882
|
|
|
830
|
-
void uv_process_pipe_write_req(
|
|
883
|
+
void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
|
|
884
|
+
uv_write_t* req) {
|
|
831
885
|
assert(handle->type == UV_NAMED_PIPE);
|
|
832
886
|
|
|
833
887
|
handle->write_queue_size -= req->queued_bytes;
|
|
834
888
|
|
|
835
889
|
if (req->cb) {
|
|
836
|
-
|
|
837
|
-
|
|
890
|
+
if (!REQ_SUCCESS(req)) {
|
|
891
|
+
loop->last_error = GET_REQ_UV_ERROR(req);
|
|
892
|
+
((uv_write_cb)req->cb)(req, -1);
|
|
893
|
+
} else {
|
|
894
|
+
((uv_write_cb)req->cb)(req, 0);
|
|
895
|
+
}
|
|
838
896
|
}
|
|
839
897
|
|
|
840
898
|
handle->write_reqs_pending--;
|
|
841
899
|
if (handle->write_reqs_pending == 0 &&
|
|
842
900
|
handle->flags & UV_HANDLE_SHUTTING) {
|
|
843
|
-
uv_want_endgame((uv_handle_t*)handle);
|
|
901
|
+
uv_want_endgame(loop, (uv_handle_t*)handle);
|
|
844
902
|
}
|
|
845
903
|
|
|
846
904
|
DECREASE_PENDING_REQ_COUNT(handle);
|
|
847
905
|
}
|
|
848
906
|
|
|
849
907
|
|
|
850
|
-
void uv_process_pipe_accept_req(
|
|
908
|
+
void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
|
|
909
|
+
uv_req_t* raw_req) {
|
|
851
910
|
uv_pipe_accept_t* req = (uv_pipe_accept_t*) raw_req;
|
|
852
911
|
|
|
853
912
|
assert(handle->type == UV_NAMED_PIPE);
|
|
854
913
|
|
|
855
|
-
if (req
|
|
914
|
+
if (REQ_SUCCESS(req)) {
|
|
856
915
|
assert(req->pipeHandle != INVALID_HANDLE_VALUE);
|
|
857
916
|
req->next_pending = handle->pending_accepts;
|
|
858
917
|
handle->pending_accepts = req;
|
|
@@ -867,7 +926,7 @@ void uv_process_pipe_accept_req(uv_pipe_t* handle, uv_req_t* raw_req) {
|
|
|
867
926
|
}
|
|
868
927
|
if (!(handle->flags & UV_HANDLE_CLOSING) &&
|
|
869
928
|
!(handle->flags & UV_HANDLE_GIVEN_OS_HANDLE)) {
|
|
870
|
-
uv_pipe_queue_accept(handle, req, FALSE);
|
|
929
|
+
uv_pipe_queue_accept(loop, handle, req, FALSE);
|
|
871
930
|
}
|
|
872
931
|
}
|
|
873
932
|
|
|
@@ -875,15 +934,16 @@ void uv_process_pipe_accept_req(uv_pipe_t* handle, uv_req_t* raw_req) {
|
|
|
875
934
|
}
|
|
876
935
|
|
|
877
936
|
|
|
878
|
-
void uv_process_pipe_connect_req(
|
|
937
|
+
void uv_process_pipe_connect_req(uv_loop_t* loop, uv_pipe_t* handle,
|
|
938
|
+
uv_connect_t* req) {
|
|
879
939
|
assert(handle->type == UV_NAMED_PIPE);
|
|
880
940
|
|
|
881
941
|
if (req->cb) {
|
|
882
|
-
if (req
|
|
883
|
-
|
|
942
|
+
if (REQ_SUCCESS(req)) {
|
|
943
|
+
uv_pipe_connection_init(handle);
|
|
884
944
|
((uv_connect_cb)req->cb)(req, 0);
|
|
885
945
|
} else {
|
|
886
|
-
|
|
946
|
+
loop->last_error = GET_REQ_UV_ERROR(req);
|
|
887
947
|
((uv_connect_cb)req->cb)(req, -1);
|
|
888
948
|
}
|
|
889
949
|
}
|
|
@@ -892,11 +952,21 @@ void uv_process_pipe_connect_req(uv_pipe_t* handle, uv_connect_t* req) {
|
|
|
892
952
|
}
|
|
893
953
|
|
|
894
954
|
|
|
895
|
-
void uv_process_pipe_shutdown_req(
|
|
955
|
+
void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
|
|
956
|
+
uv_shutdown_t* req) {
|
|
896
957
|
assert(handle->type == UV_NAMED_PIPE);
|
|
897
958
|
|
|
898
|
-
|
|
899
|
-
|
|
959
|
+
/* Initialize and optionally start the eof timer. */
|
|
960
|
+
/* This makes no sense if we've already seen EOF. */
|
|
961
|
+
if (!(handle->flags & UV_HANDLE_EOF)) {
|
|
962
|
+
eof_timer_init(handle);
|
|
963
|
+
|
|
964
|
+
/* If reading start the timer right now. */
|
|
965
|
+
/* Otherwise uv_pipe_queue_read will start it. */
|
|
966
|
+
if (handle->flags & UV_HANDLE_READ_PENDING) {
|
|
967
|
+
eof_timer_start(handle);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
900
970
|
|
|
901
971
|
if (req->cb) {
|
|
902
972
|
req->cb(req, 0);
|
|
@@ -904,3 +974,88 @@ void uv_process_pipe_shutdown_req(uv_pipe_t* handle, uv_shutdown_t* req) {
|
|
|
904
974
|
|
|
905
975
|
DECREASE_PENDING_REQ_COUNT(handle);
|
|
906
976
|
}
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
static void eof_timer_init(uv_pipe_t* pipe) {
|
|
980
|
+
int r;
|
|
981
|
+
|
|
982
|
+
assert(pipe->eof_timer == NULL);
|
|
983
|
+
assert(pipe->flags & UV_HANDLE_CONNECTION);
|
|
984
|
+
|
|
985
|
+
pipe->eof_timer = (uv_timer_t*) malloc(sizeof *pipe->eof_timer);
|
|
986
|
+
|
|
987
|
+
r = uv_timer_init(pipe->loop, pipe->eof_timer);
|
|
988
|
+
assert(r == 0); /* timers can't fail */
|
|
989
|
+
pipe->eof_timer->data = pipe;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
|
|
993
|
+
static void eof_timer_start(uv_pipe_t* pipe) {
|
|
994
|
+
assert(pipe->flags & UV_HANDLE_CONNECTION);
|
|
995
|
+
|
|
996
|
+
if (pipe->eof_timer != NULL) {
|
|
997
|
+
uv_timer_start(pipe->eof_timer, eof_timer_cb, eof_timeout, 0);
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
static void eof_timer_stop(uv_pipe_t* pipe) {
|
|
1003
|
+
assert(pipe->flags & UV_HANDLE_CONNECTION);
|
|
1004
|
+
|
|
1005
|
+
if (pipe->eof_timer != NULL) {
|
|
1006
|
+
uv_timer_stop(pipe->eof_timer);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
static void eof_timer_cb(uv_timer_t* timer, int status) {
|
|
1012
|
+
uv_pipe_t* pipe = (uv_pipe_t*) timer->data;
|
|
1013
|
+
uv_loop_t* loop = timer->loop;
|
|
1014
|
+
|
|
1015
|
+
assert(status == 0); /* timers can't fail */
|
|
1016
|
+
assert(pipe->type == UV_NAMED_PIPE);
|
|
1017
|
+
|
|
1018
|
+
/* This should always be true, since we start the timer only */
|
|
1019
|
+
/* in uv_pipe_queue_read after successfully calling ReadFile, */
|
|
1020
|
+
/* or in uv_process_pipe_shutdown_req if a read is pending, */
|
|
1021
|
+
/* and we always immediately stop the timer in */
|
|
1022
|
+
/* uv_process_pipe_read_req. */
|
|
1023
|
+
assert(pipe->flags & UV_HANDLE_READ_PENDING) ;
|
|
1024
|
+
|
|
1025
|
+
/* If there are many packets coming off the iocp then the timer callback */
|
|
1026
|
+
/* may be called before the read request is coming off the queue. */
|
|
1027
|
+
/* Therefore we check here if the read request has completed but will */
|
|
1028
|
+
/* be processed later. */
|
|
1029
|
+
if ((pipe->flags & UV_HANDLE_READ_PENDING) &&
|
|
1030
|
+
HasOverlappedIoCompleted(&pipe->read_req.overlapped)) {
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/* Force both ends off the pipe. */
|
|
1035
|
+
CloseHandle(pipe->handle);
|
|
1036
|
+
pipe->handle = INVALID_HANDLE_VALUE;
|
|
1037
|
+
|
|
1038
|
+
/* Stop reading, so the pending read that is going to fail will */
|
|
1039
|
+
/* not be reported to the user. */
|
|
1040
|
+
uv_read_stop((uv_stream_t*) pipe);
|
|
1041
|
+
|
|
1042
|
+
/* Report the eof and update flags. This will get reported even if the */
|
|
1043
|
+
/* user stopped reading in the meantime. TODO: is that okay? */
|
|
1044
|
+
uv_pipe_read_eof(loop, pipe, uv_null_buf_);
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
static void eof_timer_destroy(uv_pipe_t* pipe) {
|
|
1049
|
+
assert(pipe->flags && UV_HANDLE_CONNECTION);
|
|
1050
|
+
|
|
1051
|
+
if (pipe->eof_timer) {
|
|
1052
|
+
uv_close((uv_handle_t*) pipe->eof_timer, eof_timer_close_cb);
|
|
1053
|
+
pipe->eof_timer = NULL;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
static void eof_timer_close_cb(uv_handle_t* handle) {
|
|
1059
|
+
assert(handle->type == UV_TIMER);
|
|
1060
|
+
free(handle);
|
|
1061
|
+
}
|