noderb 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/noderb_extension/libuv/AUTHORS +11 -1
- data/ext/noderb_extension/libuv/LICENSE +0 -8
- data/ext/noderb_extension/libuv/Makefile +5 -5
- data/ext/noderb_extension/libuv/README +11 -6
- data/ext/noderb_extension/libuv/common.gypi +158 -7
- data/ext/noderb_extension/libuv/config-unix.mk +34 -26
- data/ext/noderb_extension/libuv/gyp_uv +22 -4
- data/ext/noderb_extension/libuv/include/{eio.h → uv-private/eio.h} +2 -2
- data/ext/noderb_extension/libuv/include/{uv-unix.h → uv-private/uv-unix.h} +40 -0
- data/ext/noderb_extension/libuv/include/{uv-win.h → uv-private/uv-win.h} +96 -14
- data/ext/noderb_extension/libuv/include/uv.h +508 -83
- data/ext/noderb_extension/libuv/src/unix/cares.c +185 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +828 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_darwin.h +4 -0
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_linux.h +5 -15
- data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.c +23 -2
- data/ext/noderb_extension/libuv/src/unix/error.c +102 -0
- data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_linux.h +26 -15
- data/ext/noderb_extension/libuv/src/unix/fs.c +562 -0
- data/ext/noderb_extension/libuv/src/unix/internal.h +75 -0
- data/ext/noderb_extension/libuv/src/unix/pipe.c +282 -0
- data/ext/noderb_extension/libuv/src/unix/process.c +287 -0
- data/ext/noderb_extension/libuv/src/unix/stream.c +727 -0
- data/ext/noderb_extension/libuv/src/unix/tcp.c +226 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +524 -0
- data/ext/noderb_extension/libuv/src/{uv-eio.c → unix/uv-eio.c} +48 -27
- data/ext/noderb_extension/libuv/src/{uv-eio.h → unix/uv-eio.h} +1 -1
- data/ext/noderb_extension/libuv/src/uv-common.c +24 -14
- data/ext/noderb_extension/libuv/src/uv-common.h +12 -7
- data/ext/noderb_extension/libuv/src/win/async.c +14 -16
- data/ext/noderb_extension/libuv/src/win/cares.c +64 -79
- data/ext/noderb_extension/libuv/src/win/core.c +105 -53
- data/ext/noderb_extension/libuv/src/win/error.c +23 -13
- data/ext/noderb_extension/libuv/src/win/fs.c +807 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +61 -41
- data/ext/noderb_extension/libuv/src/win/handle.c +56 -30
- data/ext/noderb_extension/libuv/src/win/internal.h +134 -95
- data/ext/noderb_extension/libuv/src/win/loop-watcher.c +21 -18
- data/ext/noderb_extension/libuv/src/win/pipe.c +313 -158
- data/ext/noderb_extension/libuv/src/win/process.c +117 -131
- data/ext/noderb_extension/libuv/src/win/req.c +55 -31
- data/ext/noderb_extension/libuv/src/win/stdio.c +5 -5
- data/ext/noderb_extension/libuv/src/win/stream.c +19 -14
- data/ext/noderb_extension/libuv/src/win/tcp.c +278 -336
- data/ext/noderb_extension/libuv/src/win/threadpool.c +73 -0
- data/ext/noderb_extension/libuv/src/win/timer.c +44 -37
- data/ext/noderb_extension/libuv/src/win/udp.c +592 -0
- data/ext/noderb_extension/libuv/src/win/util.c +20 -6
- data/ext/noderb_extension/libuv/src/win/winapi.c +23 -6
- data/ext/noderb_extension/libuv/src/win/winapi.h +4206 -0
- data/ext/noderb_extension/libuv/src/win/winsock.c +270 -0
- data/ext/noderb_extension/libuv/src/win/winsock.h +134 -0
- data/ext/noderb_extension/libuv/test/benchmark-ares.c +10 -6
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +10 -7
- data/ext/noderb_extension/libuv/test/benchmark-list.h +21 -0
- data/ext/noderb_extension/libuv/test/benchmark-ping-pongs.c +11 -7
- data/ext/noderb_extension/libuv/test/benchmark-pound.c +147 -58
- data/ext/noderb_extension/libuv/test/benchmark-pump.c +29 -23
- data/ext/noderb_extension/libuv/test/benchmark-spawn.c +13 -10
- data/ext/noderb_extension/libuv/test/benchmark-udp-packet-storm.c +250 -0
- data/ext/noderb_extension/libuv/test/dns-server.c +11 -6
- data/ext/noderb_extension/libuv/test/echo-server.c +30 -22
- data/ext/noderb_extension/libuv/test/test-async.c +3 -3
- data/ext/noderb_extension/libuv/test/test-callback-stack.c +6 -6
- data/ext/noderb_extension/libuv/test/test-connection-fail.c +6 -5
- data/ext/noderb_extension/libuv/test/test-delayed-accept.c +13 -13
- data/ext/noderb_extension/libuv/test/test-fs.c +715 -0
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +11 -8
- data/ext/noderb_extension/libuv/test/test-gethostbyname.c +8 -9
- data/ext/noderb_extension/libuv/test/test-getsockname.c +142 -16
- data/ext/noderb_extension/libuv/test/test-idle.c +4 -3
- data/ext/noderb_extension/libuv/test/test-list.h +29 -2
- data/ext/noderb_extension/libuv/test/test-loop-handles.c +9 -8
- data/ext/noderb_extension/libuv/test/test-ping-pong.c +9 -9
- data/ext/noderb_extension/libuv/test/test-pipe-bind-error.c +18 -14
- data/ext/noderb_extension/libuv/test/test-ref.c +17 -16
- data/ext/noderb_extension/libuv/test/test-shutdown-eof.c +5 -5
- data/ext/noderb_extension/libuv/test/test-spawn.c +17 -17
- data/ext/noderb_extension/libuv/test/test-tcp-bind-error.c +24 -18
- data/ext/noderb_extension/libuv/test/test-tcp-bind6-error.c +19 -14
- data/ext/noderb_extension/libuv/test/test-tcp-writealot.c +6 -5
- data/ext/noderb_extension/libuv/test/test-threadpool.c +59 -0
- data/ext/noderb_extension/libuv/test/test-timer-again.c +15 -12
- data/ext/noderb_extension/libuv/test/test-timer.c +8 -8
- data/ext/noderb_extension/libuv/test/test-udp-dgram-too-big.c +88 -0
- data/ext/noderb_extension/libuv/test/test-udp-ipv6.c +158 -0
- data/ext/noderb_extension/libuv/test/test-udp-send-and-recv.c +210 -0
- data/ext/noderb_extension/libuv/{all.gyp → uv.gyp} +75 -77
- data/ext/noderb_extension/libuv/vcbuild.bat +93 -0
- data/ext/noderb_extension/noderb.c +13 -0
- data/ext/noderb_extension/noderb_common.h +2 -1
- data/ext/noderb_extension/noderb_defer.c +54 -0
- data/ext/noderb_extension/noderb_defer.h +15 -0
- data/ext/noderb_extension/noderb_dns.c +1 -1
- data/ext/noderb_extension/noderb_fs.c +277 -0
- data/ext/noderb_extension/noderb_fs.h +27 -0
- data/ext/noderb_extension/noderb_process.c +5 -5
- data/ext/noderb_extension/noderb_tcp.c +10 -6
- data/ext/noderb_extension/noderb_timers.c +1 -1
- data/ext/noderb_extension/noderb_tools.c +42 -8
- data/ext/noderb_extension/noderb_tools.h +3 -1
- data/lib/noderb/defer.rb +25 -0
- data/lib/noderb/file.rb +119 -0
- data/lib/noderb/fs.rb +72 -0
- data/lib/noderb/version.rb +1 -1
- data/lib/noderb.rb +8 -0
- metadata +102 -266
- data/ext/noderb_extension/libuv/BSDmakefile +0 -2
- data/ext/noderb_extension/libuv/create-msvs-files.bat +0 -21
- data/ext/noderb_extension/libuv/deps/pthread-win32/ANNOUNCE +0 -482
- data/ext/noderb_extension/libuv/deps/pthread-win32/BUGS +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/Bmakefile +0 -268
- data/ext/noderb_extension/libuv/deps/pthread-win32/CONTRIBUTORS +0 -140
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING +0 -150
- data/ext/noderb_extension/libuv/deps/pthread-win32/COPYING.LIB +0 -504
- data/ext/noderb_extension/libuv/deps/pthread-win32/ChangeLog +0 -5194
- data/ext/noderb_extension/libuv/deps/pthread-win32/FAQ +0 -451
- data/ext/noderb_extension/libuv/deps/pthread-win32/GNUmakefile +0 -593
- data/ext/noderb_extension/libuv/deps/pthread-win32/MAINTAINERS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/Makefile +0 -516
- data/ext/noderb_extension/libuv/deps/pthread-win32/NEWS +0 -1245
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile +0 -24
- data/ext/noderb_extension/libuv/deps/pthread-win32/Nmakefile.tests +0 -260
- data/ext/noderb_extension/libuv/deps/pthread-win32/PROGRESS +0 -4
- data/ext/noderb_extension/libuv/deps/pthread-win32/README +0 -601
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Borland +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.CV +0 -3036
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.NONPORTABLE +0 -783
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.Watcom +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/README.WinCE +0 -6
- data/ext/noderb_extension/libuv/deps/pthread-win32/TODO +0 -7
- data/ext/noderb_extension/libuv/deps/pthread-win32/WinCE-PORT +0 -222
- data/ext/noderb_extension/libuv/deps/pthread-win32/attr.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/autostatic.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/barrier.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/build/all.gyp +0 -207
- data/ext/noderb_extension/libuv/deps/pthread-win32/builddmc.bat +0 -9
- data/ext/noderb_extension/libuv/deps/pthread-win32/cancel.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/cleanup.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/condvar.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/config.h +0 -153
- data/ext/noderb_extension/libuv/deps/pthread-win32/context.h +0 -74
- data/ext/noderb_extension/libuv/deps/pthread-win32/create.c +0 -308
- data/ext/noderb_extension/libuv/deps/pthread-win32/dll.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/errno.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/exit.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/fork.c +0 -39
- data/ext/noderb_extension/libuv/deps/pthread-win32/global.c +0 -107
- data/ext/noderb_extension/libuv/deps/pthread-win32/implement.h +0 -944
- data/ext/noderb_extension/libuv/deps/pthread-win32/misc.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/mutex.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/need_errno.h +0 -145
- data/ext/noderb_extension/libuv/deps/pthread-win32/nonportable.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/private.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.c +0 -66
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsp +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.dsw +0 -29
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread.h +0 -1368
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_destroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getdetachstate.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getinheritsched.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedparam.c +0 -52
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getschedpolicy.c +0 -61
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getscope.c +0 -54
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_getstacksize.c +0 -100
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_init.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setdetachstate.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setinheritsched.c +0 -57
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedparam.c +0 -63
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setschedpolicy.c +0 -55
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setscope.c +0 -62
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstackaddr.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_attr_setstacksize.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_destroy.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_init.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrier_wait.c +0 -104
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_init.c +0 -85
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_barrierattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cancel.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_destroy.c +0 -253
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_init.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_signal.c +0 -231
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_cond_wait.c +0 -567
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_destroy.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_init.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_condattr_setpshared.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_delay_np.c +0 -172
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_detach.c +0 -136
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_equal.c +0 -76
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_exit.c +0 -106
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getconcurrency.c +0 -45
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getschedparam.c +0 -75
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getspecific.c +0 -87
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getunique_np.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_getw32threadhandle_np.c +0 -65
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_join.c +0 -157
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_create.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_key_delete.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_kill.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_consistent.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_destroy.c +0 -148
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_init.c +0 -130
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_lock.c +0 -269
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_timedlock.c +0 -324
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_trylock.c +0 -154
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutex_unlock.c +0 -175
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_destroy.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getpshared.c +0 -95
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_getrobust.c +0 -113
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_gettype.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_init.c +0 -86
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setkind_np.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setpshared.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_setrobust.c +0 -119
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_mutexattr_settype.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_num_processors_np.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_once.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_destroy.c +0 -143
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_init.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_rdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedrdlock.c +0 -109
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_timedwrlock.c +0 -139
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_tryrdlock.c +0 -102
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_trywrlock.c +0 -122
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_unlock.c +0 -93
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlock_wrlock.c +0 -133
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_destroy.c +0 -84
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_getpshared.c +0 -97
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_init.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_rwlockattr_setpshared.c +0 -120
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_self.c +0 -141
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcancelstate.c +0 -125
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setcanceltype.c +0 -126
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setconcurrency.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setschedparam.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_setspecific.c +0 -167
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_destroy.c +0 -111
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_init.c +0 -123
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_lock.c +0 -80
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_trylock.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_spin_unlock.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_testcancel.c +0 -103
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_timechange_handler_np.c +0 -108
- data/ext/noderb_extension/libuv/deps/pthread-win32/pthread_win32_attach_detach_np.c +0 -258
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_MCS_lock.c +0 -278
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_callUserDestroyRoutines.c +0 -232
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_calloc.c +0 -56
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_cond_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_getprocessors.c +0 -91
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_is_attr.c +0 -47
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_mutex_check_need_init.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_new.c +0 -94
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processInitialize.c +0 -92
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_processTerminate.c +0 -105
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_relmillisecs.c +0 -132
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_reuse.c +0 -151
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_cancelwrwait.c +0 -50
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_rwlock_check_need_init.c +0 -77
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_semwait.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_spinlock_check_need_init.c +0 -78
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadDestroy.c +0 -79
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_threadStart.c +0 -357
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_throw.c +0 -189
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_timespec.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocCreate.c +0 -118
- data/ext/noderb_extension/libuv/deps/pthread-win32/ptw32_tkAssocDestroy.c +0 -114
- data/ext/noderb_extension/libuv/deps/pthread-win32/rwlock.c +0 -51
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.c +0 -53
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched.h +0 -183
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_max.c +0 -134
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_get_priority_min.c +0 -135
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_getscheduler.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_setscheduler.c +0 -83
- data/ext/noderb_extension/libuv/deps/pthread-win32/sched_yield.c +0 -71
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_close.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_destroy.c +0 -144
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_getvalue.c +0 -110
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_init.c +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_open.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post.c +0 -128
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_post_multiple.c +0 -142
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_timedwait.c +0 -238
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_trywait.c +0 -117
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_unlink.c +0 -58
- data/ext/noderb_extension/libuv/deps/pthread-win32/sem_wait.c +0 -187
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.c +0 -69
- data/ext/noderb_extension/libuv/deps/pthread-win32/semaphore.h +0 -169
- data/ext/noderb_extension/libuv/deps/pthread-win32/signal.c +0 -179
- data/ext/noderb_extension/libuv/deps/pthread-win32/spin.c +0 -46
- data/ext/noderb_extension/libuv/deps/pthread-win32/sync.c +0 -43
- data/ext/noderb_extension/libuv/deps/pthread-win32/tsd.c +0 -44
- data/ext/noderb_extension/libuv/deps/pthread-win32/version.rc +0 -388
- data/ext/noderb_extension/libuv/deps/pthread-win32/w32_CancelableWait.c +0 -161
- data/ext/noderb_extension/libuv/doc/iocp-links.html +0 -574
- data/ext/noderb_extension/libuv/src/uv-unix.c +0 -2421
- data/ext/noderb_extension/libuv/src/win/ntdll.h +0 -130
- /data/ext/noderb_extension/libuv/include/{ev.h → uv-private/ev.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{ngx-queue.h → uv-private/ngx-queue.h} +0 -0
- /data/ext/noderb_extension/libuv/include/{tree.h → uv-private/tree.h} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-cygwin.c → unix/cygwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-darwin.c → unix/darwin.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/demo.c +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/ecb.h +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/eio.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/libeio.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{eio → unix/eio}/xthread.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Changes +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/LICENSE +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.am +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/Makefile.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/README +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/aclocal.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/autogen.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.guess +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.h.in +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config.sub +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_cygwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_darwin.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_freebsd.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/config_sunos.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/configure.ac +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/depcomp +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev++.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.3 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev.pod +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_epoll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_kqueue.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_poll.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_port.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_select.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_vars.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_win32.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ev_wrap.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.c +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/event.h +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/install-sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/libev.m4 +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/ltmain.sh +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/missing +0 -0
- /data/ext/noderb_extension/libuv/src/{ev → unix/ev}/mkinstalldirs +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-freebsd.c → unix/freebsd.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-linux.c → unix/linux.c} +0 -0
- /data/ext/noderb_extension/libuv/src/{uv-sunos.c → unix/sunos.c} +0 -0
@@ -0,0 +1,715 @@
|
|
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
|
+
/* FIXME we shouldnt need to branch in this file */
|
23
|
+
#define UNIX (defined(__unix__) || defined(__POSIX__) || defined(__APPLE__))
|
24
|
+
|
25
|
+
#include "uv.h"
|
26
|
+
#include "task.h"
|
27
|
+
|
28
|
+
#include <string.h> /* memset */
|
29
|
+
#include <fcntl.h>
|
30
|
+
#include <sys/stat.h>
|
31
|
+
|
32
|
+
|
33
|
+
#if !UNIX
|
34
|
+
# include <direct.h>
|
35
|
+
# include <io.h>
|
36
|
+
# define unlink _unlink
|
37
|
+
# define rmdir _rmdir
|
38
|
+
# define stat _stat
|
39
|
+
# define open _open
|
40
|
+
# define write _write
|
41
|
+
# define lseek _lseek
|
42
|
+
# define close _close
|
43
|
+
#endif
|
44
|
+
|
45
|
+
static int close_cb_count;
|
46
|
+
static int create_cb_count;
|
47
|
+
static int open_cb_count;
|
48
|
+
static int read_cb_count;
|
49
|
+
static int write_cb_count;
|
50
|
+
static int unlink_cb_count;
|
51
|
+
static int mkdir_cb_count;
|
52
|
+
static int rmdir_cb_count;
|
53
|
+
static int readdir_cb_count;
|
54
|
+
static int stat_cb_count;
|
55
|
+
static int rename_cb_count;
|
56
|
+
static int fsync_cb_count;
|
57
|
+
static int fdatasync_cb_count;
|
58
|
+
static int ftruncate_cb_count;
|
59
|
+
static int sendfile_cb_count;
|
60
|
+
static int fstat_cb_count;
|
61
|
+
static int chmod_cb_count;
|
62
|
+
static int fchmod_cb_count;
|
63
|
+
|
64
|
+
static uv_loop_t* loop;
|
65
|
+
|
66
|
+
static uv_fs_t open_req1;
|
67
|
+
static uv_fs_t open_req2;
|
68
|
+
static uv_fs_t read_req;
|
69
|
+
static uv_fs_t write_req;
|
70
|
+
static uv_fs_t unlink_req;
|
71
|
+
static uv_fs_t close_req;
|
72
|
+
static uv_fs_t mkdir_req;
|
73
|
+
static uv_fs_t rmdir_req;
|
74
|
+
static uv_fs_t readdir_req;
|
75
|
+
static uv_fs_t stat_req;
|
76
|
+
static uv_fs_t rename_req;
|
77
|
+
static uv_fs_t fsync_req;
|
78
|
+
static uv_fs_t fdatasync_req;
|
79
|
+
static uv_fs_t ftruncate_req;
|
80
|
+
static uv_fs_t sendfile_req;
|
81
|
+
|
82
|
+
static char buf[32];
|
83
|
+
static char test_buf[] = "test-buffer\n";
|
84
|
+
|
85
|
+
|
86
|
+
void check_permission(const char* filename, int mode) {
|
87
|
+
int r;
|
88
|
+
uv_fs_t req;
|
89
|
+
struct stat* s;
|
90
|
+
|
91
|
+
r = uv_fs_stat(uv_default_loop(), &req, filename, NULL);
|
92
|
+
ASSERT(r == 0);
|
93
|
+
ASSERT(req.result == 0);
|
94
|
+
|
95
|
+
s = req.ptr;
|
96
|
+
ASSERT((s->st_mode & 0777) == mode);
|
97
|
+
|
98
|
+
uv_fs_req_cleanup(&req);
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
static void fchmod_cb(uv_fs_t* req) {
|
103
|
+
ASSERT(req->fs_type == UV_FS_FCHMOD);
|
104
|
+
ASSERT(req->result == 0);
|
105
|
+
fchmod_cb_count++;
|
106
|
+
uv_fs_req_cleanup(req);
|
107
|
+
check_permission("test_file", 0600);
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
static void chmod_cb(uv_fs_t* req) {
|
112
|
+
ASSERT(req->fs_type == UV_FS_CHMOD);
|
113
|
+
ASSERT(req->result == 0);
|
114
|
+
chmod_cb_count++;
|
115
|
+
uv_fs_req_cleanup(req);
|
116
|
+
check_permission("test_file", 0200);
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
static void unlink_cb(uv_fs_t* req) {
|
121
|
+
ASSERT(req == &unlink_req);
|
122
|
+
ASSERT(req->fs_type == UV_FS_UNLINK);
|
123
|
+
ASSERT(req->result != -1);
|
124
|
+
unlink_cb_count++;
|
125
|
+
uv_fs_req_cleanup(req);
|
126
|
+
}
|
127
|
+
|
128
|
+
static void fstat_cb(uv_fs_t* req) {
|
129
|
+
struct stat* s = req->ptr;
|
130
|
+
ASSERT(req->fs_type == UV_FS_FSTAT);
|
131
|
+
ASSERT(req->result == 0);
|
132
|
+
ASSERT(s->st_size == sizeof(test_buf));
|
133
|
+
uv_fs_req_cleanup(req);
|
134
|
+
fstat_cb_count++;
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
static void close_cb(uv_fs_t* req) {
|
139
|
+
int r;
|
140
|
+
ASSERT(req == &close_req);
|
141
|
+
ASSERT(req->fs_type == UV_FS_CLOSE);
|
142
|
+
ASSERT(req->result != -1);
|
143
|
+
close_cb_count++;
|
144
|
+
uv_fs_req_cleanup(req);
|
145
|
+
if (close_cb_count == 3) {
|
146
|
+
r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
static void ftruncate_cb(uv_fs_t* req) {
|
152
|
+
int r;
|
153
|
+
ASSERT(req == &ftruncate_req);
|
154
|
+
ASSERT(req->fs_type == UV_FS_FTRUNCATE);
|
155
|
+
ASSERT(req->result != -1);
|
156
|
+
ftruncate_cb_count++;
|
157
|
+
uv_fs_req_cleanup(req);
|
158
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
|
159
|
+
}
|
160
|
+
|
161
|
+
|
162
|
+
static void read_cb(uv_fs_t* req) {
|
163
|
+
int r;
|
164
|
+
ASSERT(req == &read_req);
|
165
|
+
ASSERT(req->fs_type == UV_FS_READ);
|
166
|
+
ASSERT(req->result != -1);
|
167
|
+
read_cb_count++;
|
168
|
+
uv_fs_req_cleanup(req);
|
169
|
+
if (read_cb_count == 1) {
|
170
|
+
ASSERT(strcmp(buf, test_buf) == 0);
|
171
|
+
r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7,
|
172
|
+
ftruncate_cb);
|
173
|
+
} else {
|
174
|
+
ASSERT(strcmp(buf, "test-bu") == 0);
|
175
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
static void open_cb(uv_fs_t* req) {
|
181
|
+
int r;
|
182
|
+
ASSERT(req == &open_req1);
|
183
|
+
ASSERT(req->fs_type == UV_FS_OPEN);
|
184
|
+
if (req->result < 0) {
|
185
|
+
/* TODO get error with uv_last_error() */
|
186
|
+
fprintf(stderr, "async open error: %d\n", req->errorno);
|
187
|
+
ASSERT(0);
|
188
|
+
}
|
189
|
+
open_cb_count++;
|
190
|
+
uv_fs_req_cleanup(req);
|
191
|
+
memset(buf, 0, sizeof(buf));
|
192
|
+
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
|
193
|
+
read_cb);
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
static void fsync_cb(uv_fs_t* req) {
|
198
|
+
int r;
|
199
|
+
ASSERT(req == &fsync_req);
|
200
|
+
ASSERT(req->fs_type == UV_FS_FSYNC);
|
201
|
+
ASSERT(req->result != -1);
|
202
|
+
fsync_cb_count++;
|
203
|
+
uv_fs_req_cleanup(req);
|
204
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
static void fdatasync_cb(uv_fs_t* req) {
|
209
|
+
int r;
|
210
|
+
ASSERT(req == &fdatasync_req);
|
211
|
+
ASSERT(req->fs_type == UV_FS_FDATASYNC);
|
212
|
+
ASSERT(req->result != -1);
|
213
|
+
fdatasync_cb_count++;
|
214
|
+
uv_fs_req_cleanup(req);
|
215
|
+
r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb);
|
216
|
+
}
|
217
|
+
|
218
|
+
|
219
|
+
static void write_cb(uv_fs_t* req) {
|
220
|
+
int r;
|
221
|
+
ASSERT(req == &write_req);
|
222
|
+
ASSERT(req->fs_type == UV_FS_WRITE);
|
223
|
+
ASSERT(req->result != -1);
|
224
|
+
write_cb_count++;
|
225
|
+
uv_fs_req_cleanup(req);
|
226
|
+
r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb);
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
static void create_cb(uv_fs_t* req) {
|
231
|
+
int r;
|
232
|
+
ASSERT(req == &open_req1);
|
233
|
+
ASSERT(req->fs_type == UV_FS_OPEN);
|
234
|
+
ASSERT(req->result != -1);
|
235
|
+
create_cb_count++;
|
236
|
+
uv_fs_req_cleanup(req);
|
237
|
+
r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf),
|
238
|
+
-1, write_cb);
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
static void rename_cb(uv_fs_t* req) {
|
243
|
+
ASSERT(req == &rename_req);
|
244
|
+
ASSERT(req->fs_type == UV_FS_RENAME);
|
245
|
+
ASSERT(req->result != -1);
|
246
|
+
rename_cb_count++;
|
247
|
+
uv_fs_req_cleanup(req);
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
static void mkdir_cb(uv_fs_t* req) {
|
252
|
+
ASSERT(req == &mkdir_req);
|
253
|
+
ASSERT(req->fs_type == UV_FS_MKDIR);
|
254
|
+
ASSERT(req->result != -1);
|
255
|
+
mkdir_cb_count++;
|
256
|
+
uv_fs_req_cleanup(req);
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
static void rmdir_cb(uv_fs_t* req) {
|
261
|
+
ASSERT(req == &rmdir_req);
|
262
|
+
ASSERT(req->fs_type == UV_FS_RMDIR);
|
263
|
+
ASSERT(req->result != -1);
|
264
|
+
rmdir_cb_count++;
|
265
|
+
uv_fs_req_cleanup(req);
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
static void readdir_cb(uv_fs_t* req) {
|
270
|
+
ASSERT(req == &readdir_req);
|
271
|
+
ASSERT(req->fs_type == UV_FS_READDIR);
|
272
|
+
ASSERT(req->result == 2);
|
273
|
+
ASSERT(req->ptr);
|
274
|
+
ASSERT(strcmp((const char*)req->ptr, "file1") == 0);
|
275
|
+
ASSERT(strcmp((char*)req->ptr + strlen((const char*)req->ptr) + 1,
|
276
|
+
"file2") == 0);
|
277
|
+
readdir_cb_count++;
|
278
|
+
uv_fs_req_cleanup(req);
|
279
|
+
ASSERT(!req->ptr);
|
280
|
+
}
|
281
|
+
|
282
|
+
|
283
|
+
static void stat_cb(uv_fs_t* req) {
|
284
|
+
ASSERT(req == &stat_req);
|
285
|
+
ASSERT(req->fs_type == UV_FS_STAT || req->fs_type == UV_FS_LSTAT);
|
286
|
+
ASSERT(req->result != -1);
|
287
|
+
ASSERT(req->ptr);
|
288
|
+
stat_cb_count++;
|
289
|
+
uv_fs_req_cleanup(req);
|
290
|
+
ASSERT(!req->ptr);
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
static void sendfile_cb(uv_fs_t* req) {
|
295
|
+
ASSERT(req == &sendfile_req);
|
296
|
+
ASSERT(req->fs_type == UV_FS_SENDFILE);
|
297
|
+
ASSERT(req->result == 65546);
|
298
|
+
sendfile_cb_count++;
|
299
|
+
uv_fs_req_cleanup(req);
|
300
|
+
}
|
301
|
+
|
302
|
+
|
303
|
+
TEST_IMPL(fs_file_async) {
|
304
|
+
int r;
|
305
|
+
|
306
|
+
/* Setup. */
|
307
|
+
unlink("test_file");
|
308
|
+
unlink("test_file2");
|
309
|
+
|
310
|
+
uv_init();
|
311
|
+
loop = uv_default_loop();
|
312
|
+
|
313
|
+
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
|
314
|
+
S_IREAD | S_IWRITE, create_cb);
|
315
|
+
ASSERT(r == 0);
|
316
|
+
uv_run(loop);
|
317
|
+
|
318
|
+
ASSERT(create_cb_count == 1);
|
319
|
+
ASSERT(write_cb_count == 1);
|
320
|
+
ASSERT(fsync_cb_count == 1);
|
321
|
+
ASSERT(fdatasync_cb_count == 1);
|
322
|
+
ASSERT(close_cb_count == 1);
|
323
|
+
|
324
|
+
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", rename_cb);
|
325
|
+
ASSERT(r == 0);
|
326
|
+
|
327
|
+
uv_run(loop);
|
328
|
+
ASSERT(create_cb_count == 1);
|
329
|
+
ASSERT(write_cb_count == 1);
|
330
|
+
ASSERT(close_cb_count == 1);
|
331
|
+
ASSERT(rename_cb_count == 1);
|
332
|
+
|
333
|
+
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDWR, 0, open_cb);
|
334
|
+
ASSERT(r == 0);
|
335
|
+
|
336
|
+
uv_run(loop);
|
337
|
+
ASSERT(open_cb_count == 1);
|
338
|
+
ASSERT(read_cb_count == 1);
|
339
|
+
ASSERT(close_cb_count == 2);
|
340
|
+
ASSERT(rename_cb_count == 1);
|
341
|
+
ASSERT(create_cb_count == 1);
|
342
|
+
ASSERT(write_cb_count == 1);
|
343
|
+
ASSERT(ftruncate_cb_count == 1);
|
344
|
+
|
345
|
+
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, open_cb);
|
346
|
+
ASSERT(r == 0);
|
347
|
+
|
348
|
+
uv_run(loop);
|
349
|
+
ASSERT(open_cb_count == 2);
|
350
|
+
ASSERT(read_cb_count == 2);
|
351
|
+
ASSERT(close_cb_count == 3);
|
352
|
+
ASSERT(rename_cb_count == 1);
|
353
|
+
ASSERT(unlink_cb_count == 1);
|
354
|
+
ASSERT(create_cb_count == 1);
|
355
|
+
ASSERT(write_cb_count == 1);
|
356
|
+
ASSERT(ftruncate_cb_count == 1);
|
357
|
+
|
358
|
+
/* Cleanup. */
|
359
|
+
unlink("test_file");
|
360
|
+
unlink("test_file2");
|
361
|
+
|
362
|
+
return 0;
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
TEST_IMPL(fs_file_sync) {
|
367
|
+
int r;
|
368
|
+
|
369
|
+
/* Setup. */
|
370
|
+
unlink("test_file");
|
371
|
+
unlink("test_file2");
|
372
|
+
|
373
|
+
uv_init();
|
374
|
+
loop = uv_default_loop();
|
375
|
+
|
376
|
+
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
|
377
|
+
S_IWRITE | S_IREAD, NULL);
|
378
|
+
ASSERT(r == 0);
|
379
|
+
ASSERT(open_req1.result != -1);
|
380
|
+
uv_fs_req_cleanup(&open_req1);
|
381
|
+
|
382
|
+
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf,
|
383
|
+
sizeof(test_buf), -1, NULL);
|
384
|
+
ASSERT(r == 0);
|
385
|
+
ASSERT(write_req.result != -1);
|
386
|
+
uv_fs_req_cleanup(&write_req);
|
387
|
+
|
388
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
389
|
+
ASSERT(r == 0);
|
390
|
+
ASSERT(close_req.result != -1);
|
391
|
+
uv_fs_req_cleanup(&close_req);
|
392
|
+
|
393
|
+
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL);
|
394
|
+
ASSERT(r == 0);
|
395
|
+
ASSERT(open_req1.result != -1);
|
396
|
+
uv_fs_req_cleanup(&open_req1);
|
397
|
+
|
398
|
+
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
|
399
|
+
NULL);
|
400
|
+
ASSERT(r == 0);
|
401
|
+
ASSERT(read_req.result != -1);
|
402
|
+
ASSERT(strcmp(buf, test_buf) == 0);
|
403
|
+
uv_fs_req_cleanup(&read_req);
|
404
|
+
|
405
|
+
r = uv_fs_ftruncate(loop, &ftruncate_req, open_req1.result, 7, NULL);
|
406
|
+
ASSERT(r == 0);
|
407
|
+
ASSERT(ftruncate_req.result != -1);
|
408
|
+
uv_fs_req_cleanup(&ftruncate_req);
|
409
|
+
|
410
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
411
|
+
ASSERT(r == 0);
|
412
|
+
ASSERT(close_req.result != -1);
|
413
|
+
uv_fs_req_cleanup(&close_req);
|
414
|
+
|
415
|
+
r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL);
|
416
|
+
ASSERT(r == 0);
|
417
|
+
ASSERT(rename_req.result != -1);
|
418
|
+
uv_fs_req_cleanup(&rename_req);
|
419
|
+
|
420
|
+
r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL);
|
421
|
+
ASSERT(r == 0);
|
422
|
+
ASSERT(open_req1.result != -1);
|
423
|
+
uv_fs_req_cleanup(&open_req1);
|
424
|
+
|
425
|
+
memset(buf, 0, sizeof(buf));
|
426
|
+
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
|
427
|
+
NULL);
|
428
|
+
ASSERT(r == 0);
|
429
|
+
ASSERT(read_req.result != -1);
|
430
|
+
ASSERT(strcmp(buf, "test-bu") == 0);
|
431
|
+
uv_fs_req_cleanup(&read_req);
|
432
|
+
|
433
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
434
|
+
ASSERT(r == 0);
|
435
|
+
ASSERT(close_req.result != -1);
|
436
|
+
uv_fs_req_cleanup(&close_req);
|
437
|
+
|
438
|
+
r = uv_fs_unlink(loop, &unlink_req, "test_file2", NULL);
|
439
|
+
ASSERT(r == 0);
|
440
|
+
ASSERT(unlink_req.result != -1);
|
441
|
+
uv_fs_req_cleanup(&unlink_req);
|
442
|
+
|
443
|
+
/* Cleanup */
|
444
|
+
unlink("test_file");
|
445
|
+
unlink("test_file2");
|
446
|
+
|
447
|
+
return 0;
|
448
|
+
}
|
449
|
+
|
450
|
+
|
451
|
+
TEST_IMPL(fs_async_dir) {
|
452
|
+
int r;
|
453
|
+
|
454
|
+
/* Setup */
|
455
|
+
unlink("test_dir/file1");
|
456
|
+
unlink("test_dir/file2");
|
457
|
+
rmdir("test_dir");
|
458
|
+
|
459
|
+
uv_init();
|
460
|
+
loop = uv_default_loop();
|
461
|
+
|
462
|
+
r = uv_fs_mkdir(loop, &mkdir_req, "test_dir", 0755, mkdir_cb);
|
463
|
+
ASSERT(r == 0);
|
464
|
+
|
465
|
+
uv_run(loop);
|
466
|
+
ASSERT(mkdir_cb_count == 1);
|
467
|
+
|
468
|
+
/* Create 2 files synchronously. */
|
469
|
+
r = uv_fs_open(loop, &open_req1, "test_dir/file1", O_WRONLY | O_CREAT,
|
470
|
+
S_IWRITE | S_IREAD, NULL);
|
471
|
+
ASSERT(r == 0);
|
472
|
+
uv_fs_req_cleanup(&open_req1);
|
473
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
474
|
+
ASSERT(r == 0);
|
475
|
+
uv_fs_req_cleanup(&close_req);
|
476
|
+
|
477
|
+
r = uv_fs_open(loop, &open_req1, "test_dir/file2", O_WRONLY | O_CREAT,
|
478
|
+
S_IWRITE | S_IREAD, NULL);
|
479
|
+
ASSERT(r == 0);
|
480
|
+
uv_fs_req_cleanup(&open_req1);
|
481
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
482
|
+
ASSERT(r == 0);
|
483
|
+
uv_fs_req_cleanup(&close_req);
|
484
|
+
|
485
|
+
r = uv_fs_readdir(loop, &readdir_req, "test_dir", 0, readdir_cb);
|
486
|
+
ASSERT(r == 0);
|
487
|
+
|
488
|
+
uv_run(loop);
|
489
|
+
ASSERT(readdir_cb_count == 1);
|
490
|
+
|
491
|
+
r = uv_fs_stat(loop, &stat_req, "test_dir", stat_cb);
|
492
|
+
ASSERT(r == 0);
|
493
|
+
uv_run(loop);
|
494
|
+
|
495
|
+
r = uv_fs_stat(loop, &stat_req, "test_dir\\", stat_cb);
|
496
|
+
ASSERT(r == 0);
|
497
|
+
uv_run(loop);
|
498
|
+
|
499
|
+
r = uv_fs_lstat(loop, &stat_req, "test_dir", stat_cb);
|
500
|
+
ASSERT(r == 0);
|
501
|
+
uv_run(loop);
|
502
|
+
|
503
|
+
r = uv_fs_lstat(loop, &stat_req, "test_dir\\", stat_cb);
|
504
|
+
ASSERT(r == 0);
|
505
|
+
uv_run(loop);
|
506
|
+
|
507
|
+
ASSERT(stat_cb_count == 4);
|
508
|
+
|
509
|
+
r = uv_fs_unlink(loop, &unlink_req, "test_dir/file1", unlink_cb);
|
510
|
+
ASSERT(r == 0);
|
511
|
+
uv_run(loop);
|
512
|
+
ASSERT(unlink_cb_count == 1);
|
513
|
+
|
514
|
+
r = uv_fs_unlink(loop, &unlink_req, "test_dir/file2", unlink_cb);
|
515
|
+
ASSERT(r == 0);
|
516
|
+
uv_run(loop);
|
517
|
+
ASSERT(unlink_cb_count == 2);
|
518
|
+
|
519
|
+
r = uv_fs_rmdir(loop, &rmdir_req, "test_dir", rmdir_cb);
|
520
|
+
ASSERT(r == 0);
|
521
|
+
uv_run(loop);
|
522
|
+
ASSERT(rmdir_cb_count == 1);
|
523
|
+
|
524
|
+
/* Cleanup */
|
525
|
+
unlink("test_dir/file1");
|
526
|
+
unlink("test_dir/file2");
|
527
|
+
rmdir("test_dir");
|
528
|
+
|
529
|
+
return 0;
|
530
|
+
}
|
531
|
+
|
532
|
+
|
533
|
+
TEST_IMPL(fs_async_sendfile) {
|
534
|
+
int f, r;
|
535
|
+
struct stat s1, s2;
|
536
|
+
|
537
|
+
/* Setup. */
|
538
|
+
uv_init();
|
539
|
+
unlink("test_file");
|
540
|
+
unlink("test_file2");
|
541
|
+
|
542
|
+
f = open("test_file", O_WRONLY | O_CREAT, S_IWRITE | S_IREAD);
|
543
|
+
ASSERT(f != -1);
|
544
|
+
|
545
|
+
r = write(f, "begin\n", 6);
|
546
|
+
ASSERT(r == 6);
|
547
|
+
|
548
|
+
r = lseek(f, 65536, SEEK_CUR);
|
549
|
+
ASSERT(r == 65542);
|
550
|
+
|
551
|
+
r = write(f, "end\n", 4);
|
552
|
+
ASSERT(r != -1);
|
553
|
+
|
554
|
+
r = close(f);
|
555
|
+
ASSERT(r == 0);
|
556
|
+
|
557
|
+
/* Test starts here. */
|
558
|
+
loop = uv_default_loop();
|
559
|
+
|
560
|
+
r = uv_fs_open(loop, &open_req1, "test_file", O_RDWR, 0, NULL);
|
561
|
+
ASSERT(r == 0);
|
562
|
+
ASSERT(open_req1.result != -1);
|
563
|
+
uv_fs_req_cleanup(&open_req1);
|
564
|
+
|
565
|
+
r = uv_fs_open(loop, &open_req2, "test_file2", O_WRONLY | O_CREAT,
|
566
|
+
S_IWRITE | S_IREAD, NULL);
|
567
|
+
ASSERT(r == 0);
|
568
|
+
ASSERT(open_req2.result != -1);
|
569
|
+
uv_fs_req_cleanup(&open_req2);
|
570
|
+
|
571
|
+
r = uv_fs_sendfile(loop, &sendfile_req, open_req2.result, open_req1.result,
|
572
|
+
0, 131072, sendfile_cb);
|
573
|
+
ASSERT(r == 0);
|
574
|
+
uv_run(loop);
|
575
|
+
|
576
|
+
ASSERT(sendfile_cb_count == 1);
|
577
|
+
|
578
|
+
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
|
579
|
+
ASSERT(r == 0);
|
580
|
+
uv_fs_req_cleanup(&close_req);
|
581
|
+
r = uv_fs_close(loop, &close_req, open_req2.result, NULL);
|
582
|
+
ASSERT(r == 0);
|
583
|
+
uv_fs_req_cleanup(&close_req);
|
584
|
+
|
585
|
+
stat("test_file", &s1);
|
586
|
+
stat("test_file2", &s2);
|
587
|
+
ASSERT(65546 == s2.st_size && s1.st_size == s2.st_size);
|
588
|
+
|
589
|
+
/* Cleanup. */
|
590
|
+
unlink("test_file");
|
591
|
+
unlink("test_file2");
|
592
|
+
|
593
|
+
return 0;
|
594
|
+
}
|
595
|
+
|
596
|
+
|
597
|
+
TEST_IMPL(fs_fstat) {
|
598
|
+
int r;
|
599
|
+
uv_fs_t req;
|
600
|
+
uv_file file;
|
601
|
+
|
602
|
+
/* Setup. */
|
603
|
+
unlink("test_file");
|
604
|
+
|
605
|
+
uv_init();
|
606
|
+
|
607
|
+
loop = uv_default_loop();
|
608
|
+
|
609
|
+
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, 0, NULL);
|
610
|
+
ASSERT(r == 0);
|
611
|
+
ASSERT(req.result != -1);
|
612
|
+
file = req.result;
|
613
|
+
uv_fs_req_cleanup(&req);
|
614
|
+
|
615
|
+
r = uv_fs_write(loop, &req, file, test_buf, sizeof(test_buf), -1, NULL);
|
616
|
+
ASSERT(r == 0);
|
617
|
+
ASSERT(req.result == sizeof(test_buf));
|
618
|
+
uv_fs_req_cleanup(&req);
|
619
|
+
|
620
|
+
r = uv_fs_fstat(loop, &req, file, NULL);
|
621
|
+
ASSERT(r == 0);
|
622
|
+
ASSERT(req.result == 0);
|
623
|
+
struct stat* s = req.ptr;
|
624
|
+
ASSERT(s->st_size == sizeof(test_buf));
|
625
|
+
uv_fs_req_cleanup(&req);
|
626
|
+
|
627
|
+
/* Now do the uv_fs_fstat call asynchronously */
|
628
|
+
r = uv_fs_fstat(loop, &req, file, fstat_cb);
|
629
|
+
ASSERT(r == 0);
|
630
|
+
uv_run(loop);
|
631
|
+
ASSERT(fstat_cb_count == 1);
|
632
|
+
|
633
|
+
|
634
|
+
r = uv_fs_close(loop, &req, file, NULL);
|
635
|
+
ASSERT(r == 0);
|
636
|
+
ASSERT(req.result == 0);
|
637
|
+
uv_fs_req_cleanup(&req);
|
638
|
+
|
639
|
+
/*
|
640
|
+
* Run the loop just to check we don't have make any extranious uv_ref()
|
641
|
+
* calls. This should drop out immediately.
|
642
|
+
*/
|
643
|
+
uv_run(loop);
|
644
|
+
|
645
|
+
/* Cleanup. */
|
646
|
+
unlink("test_file");
|
647
|
+
|
648
|
+
return 0;
|
649
|
+
}
|
650
|
+
|
651
|
+
|
652
|
+
TEST_IMPL(fs_chmod) {
|
653
|
+
int r;
|
654
|
+
uv_fs_t req;
|
655
|
+
uv_file file;
|
656
|
+
|
657
|
+
/* Setup. */
|
658
|
+
unlink("test_file");
|
659
|
+
|
660
|
+
uv_init();
|
661
|
+
|
662
|
+
loop = uv_default_loop();
|
663
|
+
|
664
|
+
r = uv_fs_open(loop, &req, "test_file", O_RDWR | O_CREAT, 0, NULL);
|
665
|
+
ASSERT(r == 0);
|
666
|
+
ASSERT(req.result != -1);
|
667
|
+
file = req.result;
|
668
|
+
uv_fs_req_cleanup(&req);
|
669
|
+
|
670
|
+
r = uv_fs_write(loop, &req, file, test_buf, sizeof(test_buf), -1, NULL);
|
671
|
+
ASSERT(r == 0);
|
672
|
+
ASSERT(req.result == sizeof(test_buf));
|
673
|
+
uv_fs_req_cleanup(&req);
|
674
|
+
|
675
|
+
/* Make the file write-only */
|
676
|
+
r = uv_fs_chmod(loop, &req, "test_file", 0200, NULL);
|
677
|
+
ASSERT(r == 0);
|
678
|
+
ASSERT(req.result == 0);
|
679
|
+
uv_fs_req_cleanup(&req);
|
680
|
+
|
681
|
+
check_permission("test_file", 0200);
|
682
|
+
|
683
|
+
/* Make the file read+write with sync uv_fs_fchmod */
|
684
|
+
r = uv_fs_fchmod(loop, &req, file, 0600, NULL);
|
685
|
+
ASSERT(r == 0);
|
686
|
+
ASSERT(req.result == 0);
|
687
|
+
uv_fs_req_cleanup(&req);
|
688
|
+
|
689
|
+
check_permission("test_file", 0600);
|
690
|
+
|
691
|
+
/* async chmod */
|
692
|
+
r = uv_fs_chmod(loop, &req, "test_file", 0200, chmod_cb);
|
693
|
+
ASSERT(r == 0);
|
694
|
+
uv_run(loop);
|
695
|
+
ASSERT(chmod_cb_count == 1);
|
696
|
+
|
697
|
+
/* async fchmod */
|
698
|
+
r = uv_fs_fchmod(loop, &req, file, 0600, fchmod_cb);
|
699
|
+
ASSERT(r == 0);
|
700
|
+
uv_run(loop);
|
701
|
+
ASSERT(fchmod_cb_count == 1);
|
702
|
+
|
703
|
+
close(file);
|
704
|
+
|
705
|
+
/*
|
706
|
+
* Run the loop just to check we don't have make any extranious uv_ref()
|
707
|
+
* calls. This should drop out immediately.
|
708
|
+
*/
|
709
|
+
uv_run(loop);
|
710
|
+
|
711
|
+
/* Cleanup. */
|
712
|
+
unlink("test_file");
|
713
|
+
|
714
|
+
return 0;
|
715
|
+
}
|