noderb 0.0.10 → 0.0.11
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/extconf.rb +15 -11
- data/ext/noderb_extension/libuv/AUTHORS +3 -0
- data/ext/noderb_extension/libuv/{README → README.md} +48 -6
- data/ext/noderb_extension/libuv/common.gypi +6 -1
- data/ext/noderb_extension/libuv/config-unix.mk +1 -1
- data/ext/noderb_extension/libuv/include/uv-private/uv-linux.h +29 -0
- data/ext/noderb_extension/libuv/include/uv-private/uv-unix.h +9 -0
- data/ext/noderb_extension/libuv/include/uv-private/uv-win.h +38 -3
- data/ext/noderb_extension/libuv/include/uv.h +55 -3
- data/ext/noderb_extension/libuv/src/unix/cares.c +1 -0
- data/ext/noderb_extension/libuv/src/unix/core.c +20 -4
- data/ext/noderb_extension/libuv/src/unix/cygwin.c +16 -0
- data/ext/noderb_extension/libuv/src/unix/darwin.c +18 -0
- data/ext/noderb_extension/libuv/src/unix/freebsd.c +18 -1
- data/ext/noderb_extension/libuv/src/unix/fs.c +18 -9
- data/ext/noderb_extension/libuv/src/unix/internal.h +24 -0
- data/ext/noderb_extension/libuv/src/unix/linux.c +133 -1
- data/ext/noderb_extension/libuv/src/unix/netbsd.c +18 -1
- data/ext/noderb_extension/libuv/src/unix/stream.c +21 -7
- data/ext/noderb_extension/libuv/src/unix/sunos.c +18 -1
- data/ext/noderb_extension/libuv/src/unix/tty.c +41 -0
- data/ext/noderb_extension/libuv/src/unix/udp.c +1 -0
- data/ext/noderb_extension/libuv/src/win/core.c +3 -0
- data/ext/noderb_extension/libuv/src/win/fs-event.c +384 -0
- data/ext/noderb_extension/libuv/src/win/getaddrinfo.c +7 -2
- data/ext/noderb_extension/libuv/src/win/handle.c +41 -0
- data/ext/noderb_extension/libuv/src/win/internal.h +36 -0
- data/ext/noderb_extension/libuv/src/win/pipe.c +3 -0
- data/ext/noderb_extension/libuv/src/win/process.c +7 -2
- data/ext/noderb_extension/libuv/src/win/req.c +10 -0
- data/ext/noderb_extension/libuv/src/win/stream.c +10 -3
- data/ext/noderb_extension/libuv/src/win/tcp.c +3 -1
- data/ext/noderb_extension/libuv/src/win/tty.c +1559 -5
- data/ext/noderb_extension/libuv/test/benchmark-getaddrinfo.c +2 -0
- data/ext/noderb_extension/libuv/test/runner-unix.c +2 -0
- data/ext/noderb_extension/libuv/test/test-fs-event.c +217 -0
- data/ext/noderb_extension/libuv/test/test-fs.c +0 -4
- data/ext/noderb_extension/libuv/test/test-getaddrinfo.c +7 -3
- data/ext/noderb_extension/libuv/test/test-list.h +23 -0
- data/ext/noderb_extension/libuv/test/test-tcp-close.c +47 -0
- data/ext/noderb_extension/libuv/test/test-tcp-write-error.c +168 -0
- data/ext/noderb_extension/libuv/test/test-timer.c +40 -0
- data/ext/noderb_extension/libuv/test/test-tty.c +56 -0
- data/ext/noderb_extension/libuv/uv.gyp +17 -18
- data/ext/noderb_extension/noderb.c +0 -2
- data/ext/noderb_extension/noderb_dns.c +6 -7
- data/ext/noderb_extension/noderb_fs.c +11 -10
- data/ext/noderb_extension/noderb_timers.c +5 -5
- data/lib/noderb/version.rb +1 -1
- metadata +8 -3
@@ -1,20 +1,24 @@
|
|
1
1
|
require "mkmf"
|
2
2
|
|
3
|
-
cflags = "
|
3
|
+
cflags = "-shared -fPIC"
|
4
|
+
ldflags = ""
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
case RUBY_PLATFORM
|
7
|
+
when /solaris/
|
8
|
+
cflags = " -G -fPIC "
|
9
|
+
CONFIG['LDSHARED'] = "$(CXX) -G -fPIC"
|
10
|
+
if CONFIG['CC'] == 'cc'
|
11
|
+
cflags = "-g -O2 -fPIC"
|
12
|
+
CONFIG['CCDLFLAGS'] = "-fPIC"
|
13
|
+
end
|
14
|
+
when /darwin/
|
15
|
+
ldflags = "-framework CoreServices"
|
13
16
|
end
|
14
17
|
|
15
|
-
$CFLAGS = CONFIG['CFLAGS'] = cflags
|
18
|
+
$CFLAGS = CONFIG['CFLAGS'] = " #{cflags} "
|
19
|
+
$LDFLAGS = CONFIG['LDFLAGS'] = " #{ldflags} "
|
16
20
|
|
17
|
-
`cd libuv;
|
21
|
+
`cd libuv; CFLAGS="#{cflags}" make; cd ..; cp libuv/uv.a libuv.a`
|
18
22
|
|
19
23
|
dir_config("uv", File.expand_path("../libuv/include", __FILE__), File.expand_path("../libuv", __FILE__))
|
20
24
|
|
@@ -21,3 +21,6 @@ Clifford Heath <clifford.heath@gmail.com>
|
|
21
21
|
Jorge Chamorro Bieling <jorge@jorgechamorro.com>
|
22
22
|
Luis Lavena <luislavena@gmail.com>
|
23
23
|
Matthew Sporleder <msporleder@gmail.com>
|
24
|
+
Erick Tryzelaar <erick.tryzelaar@gmail.com>
|
25
|
+
Isaac Z. Schlueter <i@izs.me>
|
26
|
+
Pieter Noordhuis <pcnoordhuis@gmail.com>
|
@@ -1,10 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# libuv
|
2
|
+
|
3
|
+
libuv is a new platform layer for Node. Its purpose is to abstract IOCP on
|
4
|
+
windows and libev on Unix systems. We intend to eventually contain all
|
5
|
+
platform differences in this library.
|
4
6
|
|
5
7
|
http://nodejs.org/
|
6
8
|
|
7
|
-
|
9
|
+
## Features
|
10
|
+
|
11
|
+
Implemented:
|
12
|
+
|
13
|
+
* Non-blocking TCP sockets
|
14
|
+
|
15
|
+
* Non-blocking named pipes
|
16
|
+
|
17
|
+
* UDP
|
18
|
+
|
19
|
+
* Timers
|
20
|
+
|
21
|
+
* Child process spawning
|
22
|
+
|
23
|
+
* Asynchronous DNS via c-ares or `uv_getaddrinfo`.
|
24
|
+
|
25
|
+
* Asynchronous file system APIs `uv_fs_*`
|
26
|
+
|
27
|
+
* High resolution time `uv_hrtime`
|
28
|
+
|
29
|
+
* Current executable path look up `uv_exepath`
|
30
|
+
|
31
|
+
* Thread pool scheduling `uv_queue_work`
|
32
|
+
|
33
|
+
In-progress:
|
34
|
+
|
35
|
+
* File system events (Currently supports inotify, `ReadDirectoryChangesW`
|
36
|
+
and will support kqueue and event ports in the near future.)
|
37
|
+
`uv_fs_event_t`
|
38
|
+
|
39
|
+
* VT100 TTY `uv_tty_t`
|
40
|
+
|
41
|
+
* Socket sharing between processes `uv_ipc_t`
|
42
|
+
|
43
|
+
|
44
|
+
## Documentation
|
45
|
+
|
46
|
+
See `include/uv.h`.
|
47
|
+
|
48
|
+
|
49
|
+
## Build Instructions
|
8
50
|
|
9
51
|
For GCC (including MinGW) there are two methods building: via normal
|
10
52
|
makefiles or via GYP. GYP is a meta-build system which can generate MSVS,
|
@@ -19,7 +61,7 @@ To build with Visual Studio run the vcbuilds.bat file which will
|
|
19
61
|
checkout the GYP code into build/gyp and generate the uv.sln and
|
20
62
|
related files.
|
21
63
|
|
22
|
-
Windows users can also build from cmd-line using msbuild. This is
|
64
|
+
Windows users can also build from cmd-line using msbuild. This is
|
23
65
|
done by running vcbuild.bat from Visual Studio command prompt.
|
24
66
|
|
25
67
|
To have GYP generate build script for another system you will need to
|
@@ -38,7 +80,7 @@ Macintosh users run
|
|
38
80
|
xcodebuild -project uv.xcodeproj -configuration Release -target All
|
39
81
|
|
40
82
|
|
41
|
-
|
83
|
+
## Supported Platforms
|
42
84
|
|
43
85
|
Microsoft Windows operating systems since Windows XP SP2. It can be built
|
44
86
|
with either Visual Studio or MinGW.
|
@@ -32,6 +32,11 @@
|
|
32
32
|
'LinkIncremental': 2, # enable incremental linking
|
33
33
|
},
|
34
34
|
},
|
35
|
+
'conditions': [
|
36
|
+
['OS != "win"', {
|
37
|
+
'defines': [ 'EV_VERIFY=2' ],
|
38
|
+
}],
|
39
|
+
]
|
35
40
|
},
|
36
41
|
'Release': {
|
37
42
|
'defines': [ 'NDEBUG' ],
|
@@ -113,7 +118,7 @@
|
|
113
118
|
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
|
114
119
|
'ldflags': [ '-pthread', ],
|
115
120
|
'conditions': [
|
116
|
-
[ 'target_arch=="ia32"', {
|
121
|
+
[ 'host_arch != target_arch and target_arch=="ia32"', {
|
117
122
|
'cflags': [ '-m32' ],
|
118
123
|
'ldflags': [ '-m32' ],
|
119
124
|
}],
|
@@ -0,0 +1,29 @@
|
|
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_LINUX_H
|
23
|
+
#define UV_LINUX_H
|
24
|
+
|
25
|
+
#define UV_FS_EVENT_PRIVATE_FIELDS \
|
26
|
+
ev_io read_watcher; \
|
27
|
+
uv_fs_event_cb cb; \
|
28
|
+
|
29
|
+
#endif /* UV_LINUX_H */
|
@@ -27,6 +27,10 @@
|
|
27
27
|
#include "ev.h"
|
28
28
|
#include "eio.h"
|
29
29
|
|
30
|
+
#if defined(__linux__)
|
31
|
+
#include "uv-private/uv-linux.h"
|
32
|
+
#endif
|
33
|
+
|
30
34
|
#include <sys/types.h>
|
31
35
|
#include <sys/socket.h>
|
32
36
|
#include <netdb.h>
|
@@ -42,6 +46,11 @@ typedef struct {
|
|
42
46
|
|
43
47
|
typedef int uv_file;
|
44
48
|
|
49
|
+
/* Stub. Remove it once all platforms support the file watcher API. */
|
50
|
+
#ifndef UV_FS_EVENT_PRIVATE_FIELDS
|
51
|
+
#define UV_FS_EVENT_PRIVATE_FIELDS /* empty */
|
52
|
+
#endif
|
53
|
+
|
45
54
|
#define UV_LOOP_PRIVATE_FIELDS \
|
46
55
|
ares_channel channel; \
|
47
56
|
/* \
|
@@ -86,7 +86,8 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|
86
86
|
UV_GETADDRINFO_REQ, \
|
87
87
|
UV_PROCESS_EXIT, \
|
88
88
|
UV_PROCESS_CLOSE, \
|
89
|
-
UV_UDP_RECV
|
89
|
+
UV_UDP_RECV, \
|
90
|
+
UV_FS_EVENT_REQ
|
90
91
|
|
91
92
|
#define UV_REQ_PRIVATE_FIELDS \
|
92
93
|
union { \
|
@@ -116,6 +117,7 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|
116
117
|
HANDLE pipeHandle; \
|
117
118
|
struct uv_pipe_accept_s* next_pending; \
|
118
119
|
} uv_pipe_accept_t; \
|
120
|
+
\
|
119
121
|
typedef struct uv_tcp_accept_s { \
|
120
122
|
UV_REQ_FIELDS \
|
121
123
|
SOCKET accept_socket; \
|
@@ -180,6 +182,31 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|
180
182
|
struct { uv_pipe_connection_fields }; \
|
181
183
|
};
|
182
184
|
|
185
|
+
/* TODO: put the parser states in an union - TTY handles are always */
|
186
|
+
/* half-duplex so read-state can safely overlap write-state. */
|
187
|
+
#define UV_TTY_PRIVATE_FIELDS \
|
188
|
+
HANDLE handle; \
|
189
|
+
HANDLE read_line_handle; \
|
190
|
+
uv_buf_t read_line_buffer; \
|
191
|
+
HANDLE read_raw_wait; \
|
192
|
+
DWORD original_console_mode; \
|
193
|
+
/* Fields used for translating win */ \
|
194
|
+
/* keystrokes into vt100 characters */ \
|
195
|
+
char last_key[8]; \
|
196
|
+
unsigned char last_key_offset; \
|
197
|
+
unsigned char last_key_len; \
|
198
|
+
INPUT_RECORD last_input_record; \
|
199
|
+
WCHAR last_utf16_high_surrogate; \
|
200
|
+
/* utf8-to-utf16 conversion state */ \
|
201
|
+
unsigned char utf8_bytes_left; \
|
202
|
+
unsigned int utf8_codepoint; \
|
203
|
+
/* eol conversion state */ \
|
204
|
+
unsigned char previous_eol; \
|
205
|
+
/* ansi parser state */ \
|
206
|
+
unsigned char ansi_parser_state; \
|
207
|
+
unsigned char ansi_csi_argc; \
|
208
|
+
unsigned short ansi_csi_argv[4];
|
209
|
+
|
183
210
|
#define UV_TIMER_PRIVATE_FIELDS \
|
184
211
|
RB_ENTRY(uv_timer_s) tree_entry; \
|
185
212
|
int64_t due; \
|
@@ -261,8 +288,16 @@ RB_HEAD(uv_timer_tree_s, uv_timer_s);
|
|
261
288
|
|
262
289
|
#define UV_WORK_PRIVATE_FIELDS \
|
263
290
|
|
264
|
-
|
265
|
-
|
291
|
+
#define UV_FS_EVENT_PRIVATE_FIELDS \
|
292
|
+
struct uv_fs_event_req_s { \
|
293
|
+
UV_REQ_FIELDS \
|
294
|
+
} req; \
|
295
|
+
HANDLE dir_handle; \
|
296
|
+
int req_pending; \
|
297
|
+
uv_fs_event_cb cb; \
|
298
|
+
wchar_t* filew; \
|
299
|
+
int is_path_dir; \
|
300
|
+
char* buffer;
|
266
301
|
|
267
302
|
int uv_utf16_to_utf8(const wchar_t* utf16Buffer, size_t utf16Size,
|
268
303
|
char* utf8Buffer, size_t utf8Size);
|
@@ -65,6 +65,8 @@ typedef struct uv_write_s uv_write_t;
|
|
65
65
|
typedef struct uv_connect_s uv_connect_t;
|
66
66
|
typedef struct uv_udp_send_s uv_udp_send_t;
|
67
67
|
typedef struct uv_fs_s uv_fs_t;
|
68
|
+
/* uv_fs_event_t is a subclass of uv_handle_t. */
|
69
|
+
typedef struct uv_fs_event_s uv_fs_event_t;
|
68
70
|
typedef struct uv_work_s uv_work_t;
|
69
71
|
|
70
72
|
#if defined(__unix__) || defined(__POSIX__) || defined(__APPLE__)
|
@@ -137,6 +139,15 @@ typedef void (*uv_fs_cb)(uv_fs_t* req);
|
|
137
139
|
typedef void (*uv_work_cb)(uv_work_t* req);
|
138
140
|
typedef void (*uv_after_work_cb)(uv_work_t* req);
|
139
141
|
|
142
|
+
/*
|
143
|
+
* This will be called repeatedly after the uv_fs_event_t is initialized.
|
144
|
+
* If uv_fs_event_t was initialized with a directory the filename parameter
|
145
|
+
* will be a relative path to a file contained in the directory.
|
146
|
+
* The events paramenter is an ORed mask of enum uv_fs_event elements.
|
147
|
+
*/
|
148
|
+
typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, const char* filename,
|
149
|
+
int events, int status);
|
150
|
+
|
140
151
|
|
141
152
|
/* Expand this list if necessary. */
|
142
153
|
typedef enum {
|
@@ -201,7 +212,8 @@ typedef enum {
|
|
201
212
|
UV_ASYNC,
|
202
213
|
UV_ARES_TASK,
|
203
214
|
UV_ARES_EVENT,
|
204
|
-
UV_PROCESS
|
215
|
+
UV_PROCESS,
|
216
|
+
UV_FS_EVENT
|
205
217
|
} uv_handle_type;
|
206
218
|
|
207
219
|
typedef enum {
|
@@ -607,6 +619,18 @@ int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd);
|
|
607
619
|
*/
|
608
620
|
int uv_tty_set_mode(uv_tty_t*, int mode);
|
609
621
|
|
622
|
+
/*
|
623
|
+
* Gets the current Window size. On success zero is returned.
|
624
|
+
*/
|
625
|
+
int uv_tty_get_winsize(uv_tty_t*, int* width, int* height);
|
626
|
+
|
627
|
+
/*
|
628
|
+
* Used to detect what type of stream should be used with a given file
|
629
|
+
* descriptor. Usually this will be used during initialization to guess the
|
630
|
+
* type of the stdio streams.
|
631
|
+
* For isatty() functionality use this function and test for UV_TTY.
|
632
|
+
*/
|
633
|
+
uv_handle_type uv_guess_handle(uv_file file);
|
610
634
|
|
611
635
|
/*
|
612
636
|
* uv_pipe_t is a subclass of uv_stream_t
|
@@ -779,8 +803,10 @@ struct uv_getaddrinfo_s {
|
|
779
803
|
*
|
780
804
|
* Return code 0 means that request is accepted and callback will be called
|
781
805
|
* with result. Other return codes mean that there will not be a callback.
|
782
|
-
* Input arguments may be released after return from this call.
|
783
|
-
*
|
806
|
+
* Input arguments may be released after return from this call.
|
807
|
+
*
|
808
|
+
* uv_freeaddrinfo() must be called after completion to free the addrinfo
|
809
|
+
* structure.
|
784
810
|
*/
|
785
811
|
int uv_getaddrinfo(uv_loop_t*,
|
786
812
|
uv_getaddrinfo_t* handle,
|
@@ -789,6 +815,8 @@ struct uv_getaddrinfo_s {
|
|
789
815
|
const char* service,
|
790
816
|
const struct addrinfo* hints);
|
791
817
|
|
818
|
+
void uv_freeaddrinfo(struct addrinfo* ai);
|
819
|
+
|
792
820
|
/* uv_spawn() options */
|
793
821
|
typedef struct uv_process_options_s {
|
794
822
|
uv_exit_cb exit_cb; /* Called after the process exits. */
|
@@ -997,6 +1025,27 @@ int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, int uid,
|
|
997
1025
|
int gid, uv_fs_cb cb);
|
998
1026
|
|
999
1027
|
|
1028
|
+
enum uv_fs_event {
|
1029
|
+
UV_RENAME = 1,
|
1030
|
+
UV_CHANGE = 2
|
1031
|
+
};
|
1032
|
+
|
1033
|
+
|
1034
|
+
struct uv_fs_event_s {
|
1035
|
+
UV_HANDLE_FIELDS
|
1036
|
+
char* filename;
|
1037
|
+
UV_FS_EVENT_PRIVATE_FIELDS
|
1038
|
+
};
|
1039
|
+
|
1040
|
+
|
1041
|
+
/*
|
1042
|
+
* If filename is a directory then we will watch for all events in that
|
1043
|
+
* directory. If filename is a file - we will only get events from that
|
1044
|
+
* file. Subdirectories are not watched.
|
1045
|
+
*/
|
1046
|
+
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
|
1047
|
+
const char* filename, uv_fs_event_cb cb);
|
1048
|
+
|
1000
1049
|
/* Utility */
|
1001
1050
|
|
1002
1051
|
/* Convert string ip addresses to binary structures */
|
@@ -1032,6 +1081,7 @@ union uv_any_handle {
|
|
1032
1081
|
uv_async_t async;
|
1033
1082
|
uv_timer_t timer;
|
1034
1083
|
uv_getaddrinfo_t getaddrinfo;
|
1084
|
+
uv_fs_event_t fs_event;
|
1035
1085
|
};
|
1036
1086
|
|
1037
1087
|
union uv_any_req {
|
@@ -1059,6 +1109,7 @@ struct uv_counters_s {
|
|
1059
1109
|
uint64_t async_init;
|
1060
1110
|
uint64_t timer_init;
|
1061
1111
|
uint64_t process_init;
|
1112
|
+
uint64_t fs_event_init;
|
1062
1113
|
};
|
1063
1114
|
|
1064
1115
|
|
@@ -1092,6 +1143,7 @@ struct uv_loop_s {
|
|
1092
1143
|
#undef UV_GETADDRINFO_PRIVATE_FIELDS
|
1093
1144
|
#undef UV_FS_REQ_PRIVATE_FIELDS
|
1094
1145
|
#undef UV_WORK_PRIVATE_FIELDS
|
1146
|
+
#undef UV_FS_EVENT_PRIVATE_FIELDS
|
1095
1147
|
|
1096
1148
|
#ifdef __cplusplus
|
1097
1149
|
}
|
@@ -79,6 +79,7 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
79
79
|
uv_pipe_cleanup((uv_pipe_t*)handle);
|
80
80
|
/* Fall through. */
|
81
81
|
|
82
|
+
case UV_TTY:
|
82
83
|
case UV_TCP:
|
83
84
|
stream = (uv_stream_t*)handle;
|
84
85
|
|
@@ -136,6 +137,10 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
|
|
136
137
|
ev_child_stop(process->loop->ev, &process->child_watcher);
|
137
138
|
break;
|
138
139
|
|
140
|
+
case UV_FS_EVENT:
|
141
|
+
uv__fs_event_destroy((uv_fs_event_t*)handle);
|
142
|
+
break;
|
143
|
+
|
139
144
|
default:
|
140
145
|
assert(0);
|
141
146
|
}
|
@@ -231,6 +236,7 @@ void uv__finish_close(uv_handle_t* handle) {
|
|
231
236
|
|
232
237
|
case UV_NAMED_PIPE:
|
233
238
|
case UV_TCP:
|
239
|
+
case UV_TTY:
|
234
240
|
assert(!ev_is_active(&((uv_stream_t*)handle)->read_watcher));
|
235
241
|
assert(!ev_is_active(&((uv_stream_t*)handle)->write_watcher));
|
236
242
|
assert(((uv_stream_t*)handle)->fd == -1);
|
@@ -248,6 +254,9 @@ void uv__finish_close(uv_handle_t* handle) {
|
|
248
254
|
assert(!ev_is_active(&((uv_process_t*)handle)->child_watcher));
|
249
255
|
break;
|
250
256
|
|
257
|
+
case UV_FS_EVENT:
|
258
|
+
break;
|
259
|
+
|
251
260
|
default:
|
252
261
|
assert(0);
|
253
262
|
break;
|
@@ -575,6 +584,8 @@ int64_t uv_timer_get_repeat(uv_timer_t* timer) {
|
|
575
584
|
|
576
585
|
static int uv_getaddrinfo_done(eio_req* req) {
|
577
586
|
uv_getaddrinfo_t* handle = req->data;
|
587
|
+
struct addrinfo *res = handle->res;
|
588
|
+
handle->res = NULL;
|
578
589
|
|
579
590
|
uv_unref(handle->loop);
|
580
591
|
|
@@ -587,10 +598,7 @@ static int uv_getaddrinfo_done(eio_req* req) {
|
|
587
598
|
uv_err_new(handle->loop, handle->retcode);
|
588
599
|
}
|
589
600
|
|
590
|
-
handle->cb(handle, handle->retcode,
|
591
|
-
|
592
|
-
freeaddrinfo(handle->res);
|
593
|
-
handle->res = NULL;
|
601
|
+
handle->cb(handle, handle->retcode, res);
|
594
602
|
|
595
603
|
return 0;
|
596
604
|
}
|
@@ -633,6 +641,9 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
|
633
641
|
handle->hints = malloc(sizeof(struct addrinfo));
|
634
642
|
memcpy(&handle->hints, hints, sizeof(struct addrinfo));
|
635
643
|
}
|
644
|
+
else {
|
645
|
+
handle->hints = NULL;
|
646
|
+
}
|
636
647
|
|
637
648
|
/* TODO security! check lengths, check return values. */
|
638
649
|
|
@@ -655,6 +666,11 @@ int uv_getaddrinfo(uv_loop_t* loop,
|
|
655
666
|
}
|
656
667
|
|
657
668
|
|
669
|
+
void uv_freeaddrinfo(struct addrinfo* ai) {
|
670
|
+
freeaddrinfo(ai);
|
671
|
+
}
|
672
|
+
|
673
|
+
|
658
674
|
/* Open a socket in non-blocking close-on-exec mode, atomically if possible. */
|
659
675
|
int uv__socket(int domain, int type, int protocol) {
|
660
676
|
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
|
@@ -20,8 +20,10 @@
|
|
20
20
|
|
21
21
|
#include "uv.h"
|
22
22
|
|
23
|
+
#include <assert.h>
|
23
24
|
#include <stdint.h>
|
24
25
|
#include <stddef.h>
|
26
|
+
#include <errno.h>
|
25
27
|
#include <time.h>
|
26
28
|
|
27
29
|
#undef NANOSEC
|
@@ -50,3 +52,17 @@ int uv_exepath(char* buffer, size_t* size) {
|
|
50
52
|
buffer[*size] = '\0';
|
51
53
|
return 0;
|
52
54
|
}
|
55
|
+
|
56
|
+
|
57
|
+
int uv_fs_event_init(uv_loop_t* loop,
|
58
|
+
uv_fs_event_t* handle,
|
59
|
+
const char* filename,
|
60
|
+
uv_fs_event_cb cb) {
|
61
|
+
uv_err_new(loop, ENOSYS);
|
62
|
+
return -1;
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
void uv__fs_event_destroy(uv_fs_event_t* handle) {
|
67
|
+
assert(0 && "implement me");
|
68
|
+
}
|
@@ -19,8 +19,12 @@
|
|
19
19
|
*/
|
20
20
|
|
21
21
|
#include "uv.h"
|
22
|
+
#include "internal.h"
|
22
23
|
|
24
|
+
#include <assert.h>
|
23
25
|
#include <stdint.h>
|
26
|
+
#include <errno.h>
|
27
|
+
|
24
28
|
#include <CoreServices/CoreServices.h>
|
25
29
|
#include <mach/mach.h>
|
26
30
|
#include <mach/mach_time.h>
|
@@ -63,3 +67,17 @@ int uv_exepath(char* buffer, size_t* size) {
|
|
63
67
|
*size = strlen(buffer);
|
64
68
|
return 0;
|
65
69
|
}
|
70
|
+
|
71
|
+
|
72
|
+
int uv_fs_event_init(uv_loop_t* loop,
|
73
|
+
uv_fs_event_t* handle,
|
74
|
+
const char* filename,
|
75
|
+
uv_fs_event_cb cb) {
|
76
|
+
uv_err_new(loop, ENOSYS);
|
77
|
+
return -1;
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
void uv__fs_event_destroy(uv_fs_event_t* handle) {
|
82
|
+
assert(0 && "implement me");
|
83
|
+
}
|
@@ -20,15 +20,18 @@
|
|
20
20
|
|
21
21
|
#include "uv.h"
|
22
22
|
|
23
|
+
#include <assert.h>
|
23
24
|
#include <string.h>
|
24
|
-
#include <
|
25
|
+
#include <errno.h>
|
25
26
|
|
26
27
|
#include <sys/types.h>
|
27
28
|
#include <sys/sysctl.h>
|
29
|
+
#include <time.h>
|
28
30
|
|
29
31
|
#undef NANOSEC
|
30
32
|
#define NANOSEC 1000000000
|
31
33
|
|
34
|
+
|
32
35
|
uint64_t uv_hrtime(void) {
|
33
36
|
struct timespec ts;
|
34
37
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
@@ -63,3 +66,17 @@ int uv_exepath(char* buffer, size_t* size) {
|
|
63
66
|
|
64
67
|
return 0;
|
65
68
|
}
|
69
|
+
|
70
|
+
|
71
|
+
int uv_fs_event_init(uv_loop_t* loop,
|
72
|
+
uv_fs_event_t* handle,
|
73
|
+
const char* filename,
|
74
|
+
uv_fs_event_cb cb) {
|
75
|
+
uv_err_new(loop, ENOSYS);
|
76
|
+
return -1;
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
void uv__fs_event_destroy(uv_fs_event_t* handle) {
|
81
|
+
assert(0 && "implement me");
|
82
|
+
}
|
@@ -149,19 +149,20 @@ static int uv__fs_after(eio_req* eio) {
|
|
149
149
|
case UV_FS_READLINK:
|
150
150
|
if (req->result == -1) {
|
151
151
|
req->ptr = NULL;
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
if ((name = realloc(req->eio->ptr2, req->result + 1)) == NULL) {
|
156
|
-
/* Not enough memory. Reuse buffer, chop off last byte. */
|
157
|
-
name = req->eio->ptr2;
|
158
|
-
req->result--;
|
159
|
-
}
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
assert(req->result > 0);
|
160
155
|
|
156
|
+
/* Make zero-terminated copy of req->eio->ptr2 */
|
157
|
+
if ((req->ptr = name = malloc(req->result + 1))) {
|
158
|
+
memcpy(name, req->eio->ptr2, req->result);
|
161
159
|
name[req->result] = '\0';
|
162
|
-
req->ptr = name;
|
163
160
|
req->result = 0;
|
164
161
|
}
|
162
|
+
else {
|
163
|
+
req->errorno = ENOMEM;
|
164
|
+
req->result = -1;
|
165
|
+
}
|
165
166
|
break;
|
166
167
|
|
167
168
|
default:
|
@@ -447,7 +448,15 @@ int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
|
447
448
|
|
448
449
|
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
|
449
450
|
char* path = NULL;
|
451
|
+
#if defined(__FreeBSD__) \
|
452
|
+
|| (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060)
|
453
|
+
/* freebsd and pre-10.6 darwin don't have fdatasync,
|
454
|
+
* do a full fsync instead.
|
455
|
+
*/
|
456
|
+
WRAP_EIO(UV_FS_FDATASYNC, eio_fdatasync, fsync, ARGS1(file))
|
457
|
+
#else
|
450
458
|
WRAP_EIO(UV_FS_FDATASYNC, eio_fdatasync, fdatasync, ARGS1(file))
|
459
|
+
#endif
|
451
460
|
}
|
452
461
|
|
453
462
|
|
@@ -25,6 +25,8 @@
|
|
25
25
|
#include "uv-common.h"
|
26
26
|
#include "uv-eio.h"
|
27
27
|
|
28
|
+
#include <stddef.h> /* offsetof */
|
29
|
+
|
28
30
|
#if defined(__linux__)
|
29
31
|
|
30
32
|
#include <linux/version.h>
|
@@ -51,6 +53,25 @@
|
|
51
53
|
|
52
54
|
#endif /* __linux__ */
|
53
55
|
|
56
|
+
#ifdef __APPLE__
|
57
|
+
# define HAVE_FUTIMES
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#ifdef __FreeBSD__
|
61
|
+
# define HAVE_FUTIMES
|
62
|
+
#endif
|
63
|
+
|
64
|
+
#define container_of(ptr, type, member) \
|
65
|
+
((type *) ((char *) (ptr) - offsetof(type, member)))
|
66
|
+
|
67
|
+
#define SAVE_ERRNO(block) \
|
68
|
+
do { \
|
69
|
+
int _saved_errno = errno; \
|
70
|
+
do { block; } while (0); \
|
71
|
+
errno = _saved_errno; \
|
72
|
+
} \
|
73
|
+
while (0);
|
74
|
+
|
54
75
|
/* flags */
|
55
76
|
enum {
|
56
77
|
UV_CLOSING = 0x00000001, /* uv_close() called but not finished. */
|
@@ -102,4 +123,7 @@ int uv_pipe_cleanup(uv_pipe_t* handle);
|
|
102
123
|
void uv__udp_destroy(uv_udp_t* handle);
|
103
124
|
void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w);
|
104
125
|
|
126
|
+
/* fs */
|
127
|
+
void uv__fs_event_destroy(uv_fs_event_t* handle);
|
128
|
+
|
105
129
|
#endif /* UV_UNIX_INTERNAL_H_ */
|