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
|
@@ -0,0 +1,562 @@
|
|
|
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 "uv.h"
|
|
23
|
+
#include "internal.h"
|
|
24
|
+
#include "eio.h"
|
|
25
|
+
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#include <stdlib.h>
|
|
28
|
+
#include <string.h>
|
|
29
|
+
#include <dirent.h>
|
|
30
|
+
#include <assert.h>
|
|
31
|
+
#include <errno.h>
|
|
32
|
+
#include <fcntl.h>
|
|
33
|
+
#include <unistd.h>
|
|
34
|
+
#include <utime.h>
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#define ARGS1(a) (a)
|
|
38
|
+
#define ARGS2(a,b) (a), (b)
|
|
39
|
+
#define ARGS3(a,b,c) (a), (b), (c)
|
|
40
|
+
#define ARGS4(a,b,c,d) (a), (b), (c), (d)
|
|
41
|
+
|
|
42
|
+
#define WRAP_EIO(type, eiofunc, func, args) \
|
|
43
|
+
uv_fs_req_init(loop, req, type, cb); \
|
|
44
|
+
if (cb) { \
|
|
45
|
+
/* async */ \
|
|
46
|
+
uv_ref(loop); \
|
|
47
|
+
req->eio = eiofunc(args, EIO_PRI_DEFAULT, uv__fs_after, req); \
|
|
48
|
+
if (!req->eio) { \
|
|
49
|
+
uv_err_new(loop, ENOMEM); \
|
|
50
|
+
return -1; \
|
|
51
|
+
} \
|
|
52
|
+
} else { \
|
|
53
|
+
/* sync */ \
|
|
54
|
+
req->result = func(args); \
|
|
55
|
+
if (req->result) { \
|
|
56
|
+
uv_err_new(loop, errno); \
|
|
57
|
+
return -1; \
|
|
58
|
+
} \
|
|
59
|
+
} \
|
|
60
|
+
return 0;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req, uv_fs_type fs_type,
|
|
64
|
+
uv_fs_cb cb) {
|
|
65
|
+
/* Make sure the thread pool is initialized. */
|
|
66
|
+
uv_eio_init(loop);
|
|
67
|
+
|
|
68
|
+
uv__req_init((uv_req_t*) req);
|
|
69
|
+
req->type = UV_FS;
|
|
70
|
+
req->loop = loop;
|
|
71
|
+
req->fs_type = fs_type;
|
|
72
|
+
req->cb = cb;
|
|
73
|
+
req->result = 0;
|
|
74
|
+
req->ptr = NULL;
|
|
75
|
+
req->errorno = 0;
|
|
76
|
+
req->eio = NULL;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
void uv_fs_req_cleanup(uv_fs_t* req) {
|
|
81
|
+
switch (req->fs_type) {
|
|
82
|
+
case UV_FS_READDIR:
|
|
83
|
+
assert(req->ptr);
|
|
84
|
+
free(req->ptr);
|
|
85
|
+
req->ptr = NULL;
|
|
86
|
+
break;
|
|
87
|
+
|
|
88
|
+
case UV_FS_STAT:
|
|
89
|
+
case UV_FS_LSTAT:
|
|
90
|
+
req->ptr = NULL;
|
|
91
|
+
break;
|
|
92
|
+
|
|
93
|
+
default:
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
static int uv__fs_after(eio_req* eio) {
|
|
100
|
+
char* name;
|
|
101
|
+
int namelen;
|
|
102
|
+
int buflen = 0;
|
|
103
|
+
uv_fs_t* req = eio->data;
|
|
104
|
+
int i;
|
|
105
|
+
|
|
106
|
+
assert(req->cb);
|
|
107
|
+
|
|
108
|
+
req->result = req->eio->result;
|
|
109
|
+
req->errorno = req->eio->errorno;
|
|
110
|
+
|
|
111
|
+
switch (req->fs_type) {
|
|
112
|
+
case UV_FS_READDIR:
|
|
113
|
+
/*
|
|
114
|
+
* XXX This is pretty bad.
|
|
115
|
+
* We alloc and copy the large null termiated string list from libeio.
|
|
116
|
+
* This is done because libeio is going to free eio->ptr2 after this
|
|
117
|
+
* callback. We must keep it until uv_fs_req_cleanup. If we get rid of
|
|
118
|
+
* libeio this can be avoided.
|
|
119
|
+
*/
|
|
120
|
+
buflen = 0;
|
|
121
|
+
name = req->eio->ptr2;
|
|
122
|
+
for (i = 0; i < req->result; i++) {
|
|
123
|
+
namelen = strlen(name);
|
|
124
|
+
buflen += namelen + 1;
|
|
125
|
+
/* TODO check ENOMEM */
|
|
126
|
+
name += namelen;
|
|
127
|
+
assert(*name == '\0');
|
|
128
|
+
name++;
|
|
129
|
+
}
|
|
130
|
+
req->ptr = malloc(buflen);
|
|
131
|
+
memcpy(req->ptr, req->eio->ptr2, buflen);
|
|
132
|
+
break;
|
|
133
|
+
case UV_FS_STAT:
|
|
134
|
+
case UV_FS_LSTAT:
|
|
135
|
+
case UV_FS_FSTAT:
|
|
136
|
+
req->ptr = req->eio->ptr2;
|
|
137
|
+
break;
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
uv_unref(req->loop);
|
|
144
|
+
req->eio = NULL; /* Freed by libeio */
|
|
145
|
+
|
|
146
|
+
req->cb(req);
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
|
152
|
+
WRAP_EIO(UV_FS_CLOSE, eio_close, close, ARGS1(file));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
|
157
|
+
int mode, uv_fs_cb cb) {
|
|
158
|
+
uv_fs_req_init(loop, req, UV_FS_OPEN, cb);
|
|
159
|
+
|
|
160
|
+
if (cb) {
|
|
161
|
+
/* async */
|
|
162
|
+
uv_ref(loop);
|
|
163
|
+
req->eio = eio_open(path, flags, mode, EIO_PRI_DEFAULT, uv__fs_after, req);
|
|
164
|
+
if (!req->eio) {
|
|
165
|
+
uv_err_new(loop, ENOMEM);
|
|
166
|
+
return -1;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
} else {
|
|
170
|
+
/* sync */
|
|
171
|
+
req->result = open(path, flags, mode);
|
|
172
|
+
if (req->result < 0) {
|
|
173
|
+
uv_err_new(loop, errno);
|
|
174
|
+
return -1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
uv__cloexec(req->result, 1);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file fd, void* buf,
|
|
185
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
|
186
|
+
uv_fs_req_init(loop, req, UV_FS_READ, cb);
|
|
187
|
+
|
|
188
|
+
if (cb) {
|
|
189
|
+
/* async */
|
|
190
|
+
uv_ref(loop);
|
|
191
|
+
req->eio = eio_read(fd, buf, length, offset, EIO_PRI_DEFAULT,
|
|
192
|
+
uv__fs_after, req);
|
|
193
|
+
|
|
194
|
+
if (!req->eio) {
|
|
195
|
+
uv_err_new(loop, ENOMEM);
|
|
196
|
+
return -1;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
} else {
|
|
200
|
+
/* sync */
|
|
201
|
+
req->result = offset < 0 ?
|
|
202
|
+
read(fd, buf, length) :
|
|
203
|
+
pread(fd, buf, length, offset);
|
|
204
|
+
|
|
205
|
+
if (req->result < 0) {
|
|
206
|
+
uv_err_new(loop, errno);
|
|
207
|
+
return -1;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
|
216
|
+
WRAP_EIO(UV_FS_UNLINK, eio_unlink, unlink, ARGS1(path))
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, void* buf,
|
|
221
|
+
size_t length, off_t offset, uv_fs_cb cb) {
|
|
222
|
+
uv_fs_req_init(loop, req, UV_FS_WRITE, cb);
|
|
223
|
+
|
|
224
|
+
if (cb) {
|
|
225
|
+
/* async */
|
|
226
|
+
uv_ref(loop);
|
|
227
|
+
req->eio = eio_write(file, buf, length, offset, EIO_PRI_DEFAULT,
|
|
228
|
+
uv__fs_after, req);
|
|
229
|
+
if (!req->eio) {
|
|
230
|
+
uv_err_new(loop, ENOMEM);
|
|
231
|
+
return -1;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
} else {
|
|
235
|
+
/* sync */
|
|
236
|
+
req->result = offset < 0 ?
|
|
237
|
+
write(file, buf, length) :
|
|
238
|
+
pwrite(file, buf, length, offset);
|
|
239
|
+
|
|
240
|
+
if (req->result < 0) {
|
|
241
|
+
uv_err_new(loop, errno);
|
|
242
|
+
return -1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
|
251
|
+
uv_fs_cb cb) {
|
|
252
|
+
WRAP_EIO(UV_FS_MKDIR, eio_mkdir, mkdir, ARGS2(path, mode))
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
|
257
|
+
WRAP_EIO(UV_FS_RMDIR, eio_rmdir, rmdir, ARGS1(path))
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
|
|
262
|
+
uv_fs_cb cb) {
|
|
263
|
+
int r;
|
|
264
|
+
struct dirent* entry;
|
|
265
|
+
size_t size = 0;
|
|
266
|
+
size_t d_namlen = 0;
|
|
267
|
+
|
|
268
|
+
uv_fs_req_init(loop, req, UV_FS_READDIR, cb);
|
|
269
|
+
|
|
270
|
+
if (cb) {
|
|
271
|
+
/* async */
|
|
272
|
+
uv_ref(loop);
|
|
273
|
+
req->eio = eio_readdir(path, flags, EIO_PRI_DEFAULT, uv__fs_after, req);
|
|
274
|
+
if (!req->eio) {
|
|
275
|
+
uv_err_new(loop, ENOMEM);
|
|
276
|
+
return -1;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
} else {
|
|
280
|
+
/* sync */
|
|
281
|
+
DIR* dir = opendir(path);
|
|
282
|
+
if (!dir) {
|
|
283
|
+
uv_err_new(loop, errno);
|
|
284
|
+
return -1;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
while ((entry = readdir(dir))) {
|
|
288
|
+
d_namlen = strlen(entry->d_name);
|
|
289
|
+
req->ptr = realloc(req->ptr, size + d_namlen + 1);
|
|
290
|
+
/* TODO check ENOMEM */
|
|
291
|
+
/* TODO skip . and .. */
|
|
292
|
+
memcpy((char*)req->ptr + size, entry->d_name, d_namlen);
|
|
293
|
+
size += d_namlen;
|
|
294
|
+
((char*)req->ptr)[size] = '\0';
|
|
295
|
+
size++;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
r = closedir(dir);
|
|
299
|
+
if (r) {
|
|
300
|
+
uv_err_new(loop, errno);
|
|
301
|
+
return -1;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
|
310
|
+
char* pathdup = path;
|
|
311
|
+
int pathlen;
|
|
312
|
+
|
|
313
|
+
uv_fs_req_init(loop, req, UV_FS_STAT, cb);
|
|
314
|
+
|
|
315
|
+
/* TODO do this without duplicating the string. */
|
|
316
|
+
/* TODO security */
|
|
317
|
+
pathdup = strdup(path);
|
|
318
|
+
pathlen = strlen(path);
|
|
319
|
+
|
|
320
|
+
if (pathlen > 0 && path[pathlen - 1] == '\\') {
|
|
321
|
+
/* TODO do not modify input string */
|
|
322
|
+
pathdup[pathlen - 1] = '\0';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (cb) {
|
|
326
|
+
/* async */
|
|
327
|
+
uv_ref(loop);
|
|
328
|
+
req->eio = eio_stat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req);
|
|
329
|
+
|
|
330
|
+
free(pathdup);
|
|
331
|
+
|
|
332
|
+
if (!req->eio) {
|
|
333
|
+
uv_err_new(loop, ENOMEM);
|
|
334
|
+
return -1;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
} else {
|
|
338
|
+
/* sync */
|
|
339
|
+
req->result = stat(pathdup, &req->statbuf);
|
|
340
|
+
|
|
341
|
+
free(pathdup);
|
|
342
|
+
|
|
343
|
+
if (req->result < 0) {
|
|
344
|
+
uv_err_new(loop, errno);
|
|
345
|
+
return -1;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
req->ptr = &req->statbuf;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return 0;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
|
356
|
+
uv_fs_req_init(loop, req, UV_FS_FSTAT, cb);
|
|
357
|
+
|
|
358
|
+
if (cb) {
|
|
359
|
+
/* async */
|
|
360
|
+
uv_ref(loop);
|
|
361
|
+
req->eio = eio_fstat(file, EIO_PRI_DEFAULT, uv__fs_after, req);
|
|
362
|
+
|
|
363
|
+
if (!req->eio) {
|
|
364
|
+
uv_err_new(loop, ENOMEM);
|
|
365
|
+
return -1;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
} else {
|
|
369
|
+
/* sync */
|
|
370
|
+
req->result = fstat(file, &req->statbuf);
|
|
371
|
+
|
|
372
|
+
if (req->result < 0) {
|
|
373
|
+
uv_err_new(loop, errno);
|
|
374
|
+
return -1;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
req->ptr = &req->statbuf;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return 0;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path,
|
|
385
|
+
uv_fs_cb cb) {
|
|
386
|
+
WRAP_EIO(UV_FS_RENAME, eio_rename, rename, ARGS2(path, new_path))
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
|
391
|
+
WRAP_EIO(UV_FS_FSYNC, eio_fsync, fsync, ARGS1(file))
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
|
396
|
+
WRAP_EIO(UV_FS_FDATASYNC, eio_fdatasync, fdatasync, ARGS1(file))
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, off_t offset,
|
|
401
|
+
uv_fs_cb cb) {
|
|
402
|
+
WRAP_EIO(UV_FS_FTRUNCATE, eio_ftruncate, ftruncate, ARGS2(file, offset))
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd,
|
|
407
|
+
off_t in_offset, size_t length, uv_fs_cb cb) {
|
|
408
|
+
WRAP_EIO(UV_FS_SENDFILE, eio_sendfile, eio_sendfile_sync,
|
|
409
|
+
ARGS4(out_fd, in_fd, in_offset, length))
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
|
|
414
|
+
uv_fs_cb cb) {
|
|
415
|
+
WRAP_EIO(UV_FS_CHMOD, eio_chmod, chmod, ARGS2(path, mode))
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
static int _utime(const char* path, double atime, double mtime) {
|
|
420
|
+
struct utimbuf buf;
|
|
421
|
+
buf.actime = atime;
|
|
422
|
+
buf.modtime = mtime;
|
|
423
|
+
return utime(path, &buf);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
|
|
428
|
+
double mtime, uv_fs_cb cb) {
|
|
429
|
+
WRAP_EIO(UV_FS_UTIME, eio_utime, _utime, ARGS3(path, atime, mtime))
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime,
|
|
434
|
+
double mtime, uv_fs_cb cb) {
|
|
435
|
+
assert(0 && "implement me");
|
|
436
|
+
return -1;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
|
|
441
|
+
char* pathdup = path;
|
|
442
|
+
int pathlen;
|
|
443
|
+
|
|
444
|
+
uv_fs_req_init(loop, req, UV_FS_LSTAT, cb);
|
|
445
|
+
|
|
446
|
+
/* TODO do this without duplicating the string. */
|
|
447
|
+
/* TODO security */
|
|
448
|
+
pathdup = strdup(path);
|
|
449
|
+
pathlen = strlen(path);
|
|
450
|
+
|
|
451
|
+
if (pathlen > 0 && path[pathlen - 1] == '\\') {
|
|
452
|
+
/* TODO do not modify input string */
|
|
453
|
+
pathdup[pathlen - 1] = '\0';
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (cb) {
|
|
457
|
+
/* async */
|
|
458
|
+
uv_ref(loop);
|
|
459
|
+
req->eio = eio_lstat(pathdup, EIO_PRI_DEFAULT, uv__fs_after, req);
|
|
460
|
+
|
|
461
|
+
free(pathdup);
|
|
462
|
+
|
|
463
|
+
if (!req->eio) {
|
|
464
|
+
uv_err_new(loop, ENOMEM);
|
|
465
|
+
return -1;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
} else {
|
|
469
|
+
/* sync */
|
|
470
|
+
req->result = lstat(pathdup, &req->statbuf);
|
|
471
|
+
|
|
472
|
+
free(pathdup);
|
|
473
|
+
|
|
474
|
+
if (req->result < 0) {
|
|
475
|
+
uv_err_new(loop, errno);
|
|
476
|
+
return -1;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
req->ptr = &req->statbuf;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
return 0;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
487
|
+
const char* new_path, uv_fs_cb cb) {
|
|
488
|
+
WRAP_EIO(UV_FS_LINK, eio_link, link, ARGS2(path, new_path))
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
493
|
+
const char* new_path, uv_fs_cb cb) {
|
|
494
|
+
WRAP_EIO(UV_FS_SYMLINK, eio_symlink, symlink, ARGS2(path, new_path))
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
|
|
499
|
+
uv_fs_cb cb) {
|
|
500
|
+
assert(0 && "implement me");
|
|
501
|
+
return -1;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode,
|
|
506
|
+
uv_fs_cb cb) {
|
|
507
|
+
WRAP_EIO(UV_FS_FCHMOD, eio_fchmod, fchmod, ARGS2(file, mode))
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, int uid,
|
|
512
|
+
int gid, uv_fs_cb cb) {
|
|
513
|
+
WRAP_EIO(UV_FS_CHOWN, eio_chown, chown, ARGS3(path, uid, gid))
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid, int gid,
|
|
518
|
+
uv_fs_cb cb) {
|
|
519
|
+
WRAP_EIO(UV_FS_FCHOWN, eio_fchown, fchown, ARGS3(file, uid, gid))
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
static void uv__work(eio_req* eio) {
|
|
524
|
+
uv_work_t* req = eio->data;
|
|
525
|
+
if (req->work_cb) {
|
|
526
|
+
req->work_cb(req);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
static int uv__after_work(eio_req *eio) {
|
|
532
|
+
uv_work_t* req = eio->data;
|
|
533
|
+
uv_unref(req->loop);
|
|
534
|
+
if (req->after_work_cb) {
|
|
535
|
+
req->after_work_cb(req);
|
|
536
|
+
}
|
|
537
|
+
return 0;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
int uv_queue_work(uv_loop_t* loop, uv_work_t* req, uv_work_cb work_cb,
|
|
542
|
+
uv_after_work_cb after_work_cb) {
|
|
543
|
+
void* data = req->data;
|
|
544
|
+
|
|
545
|
+
uv_eio_init(loop);
|
|
546
|
+
|
|
547
|
+
uv__req_init((uv_req_t*) req);
|
|
548
|
+
uv_ref(loop);
|
|
549
|
+
req->loop = loop;
|
|
550
|
+
req->data = data;
|
|
551
|
+
req->work_cb = work_cb;
|
|
552
|
+
req->after_work_cb = after_work_cb;
|
|
553
|
+
|
|
554
|
+
req->eio = eio_custom(uv__work, EIO_PRI_DEFAULT, uv__after_work, req);
|
|
555
|
+
|
|
556
|
+
if (!req->eio) {
|
|
557
|
+
uv_err_new(loop, ENOMEM);
|
|
558
|
+
return -1;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return 0;
|
|
562
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
#ifndef UV_UNIX_INTERNAL_H_
|
|
23
|
+
#define UV_UNIX_INTERNAL_H_
|
|
24
|
+
|
|
25
|
+
#include "uv-common.h"
|
|
26
|
+
#include "uv-eio.h"
|
|
27
|
+
|
|
28
|
+
/* flags */
|
|
29
|
+
enum {
|
|
30
|
+
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
|
|
31
|
+
UV_CLOSED = 0x00000002, /* close(2) finished. */
|
|
32
|
+
UV_READING = 0x00000004, /* uv_read_start() called. */
|
|
33
|
+
UV_SHUTTING = 0x00000008, /* uv_shutdown() called but not complete. */
|
|
34
|
+
UV_SHUT = 0x00000010, /* Write side closed. */
|
|
35
|
+
UV_READABLE = 0x00000020, /* The stream is readable */
|
|
36
|
+
UV_WRITABLE = 0x00000040 /* The stream is writable */
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
size_t uv__strlcpy(char* dst, const char* src, size_t size);
|
|
40
|
+
|
|
41
|
+
int uv__close(int fd);
|
|
42
|
+
void uv__req_init(uv_req_t*);
|
|
43
|
+
void uv__handle_init(uv_loop_t* loop, uv_handle_t* handle, uv_handle_type type);
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
int uv__nonblock(int fd, int set) __attribute__((unused));
|
|
47
|
+
int uv__cloexec(int fd, int set) __attribute__((unused));
|
|
48
|
+
int uv__socket(int domain, int type, int protocol);
|
|
49
|
+
|
|
50
|
+
/* error */
|
|
51
|
+
uv_err_t uv_err_new(uv_loop_t* loop, int sys_error);
|
|
52
|
+
uv_err_t uv_err_new_artificial(uv_loop_t* loop, int code);
|
|
53
|
+
void uv_fatal_error(const int errorno, const char* syscall);
|
|
54
|
+
|
|
55
|
+
/* stream */
|
|
56
|
+
int uv__stream_open(uv_stream_t*, int fd, int flags);
|
|
57
|
+
void uv__stream_io(EV_P_ ev_io* watcher, int revents);
|
|
58
|
+
void uv__server_io(EV_P_ ev_io* watcher, int revents);
|
|
59
|
+
int uv__accept(int sockfd, struct sockaddr* saddr, socklen_t len);
|
|
60
|
+
int uv__connect(uv_connect_t* req, uv_stream_t* stream, struct sockaddr* addr,
|
|
61
|
+
socklen_t addrlen, uv_connect_cb cb);
|
|
62
|
+
|
|
63
|
+
/* tcp */
|
|
64
|
+
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb);
|
|
65
|
+
|
|
66
|
+
/* pipe */
|
|
67
|
+
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
|
|
68
|
+
void uv__pipe_accept(EV_P_ ev_io* watcher, int revents);
|
|
69
|
+
int uv_pipe_cleanup(uv_pipe_t* handle);
|
|
70
|
+
|
|
71
|
+
/* udp */
|
|
72
|
+
void uv__udp_destroy(uv_udp_t* handle);
|
|
73
|
+
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);
|
|
74
|
+
|
|
75
|
+
#endif /* UV_UNIX_INTERNAL_H_ */
|