libuv 0.12.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4600566914f0eade37cb4fc426f3790a6a33eb5c
4
- data.tar.gz: 6d9259feca2bff661b1b08b5a38a27efd3c57b98
3
+ metadata.gz: a3fdf4a79e7b5985a3f094717f5a9c2ffe62f3df
4
+ data.tar.gz: 0f89e89ea0ef13b59a164e3cdc5a108a57f5b822
5
5
  SHA512:
6
- metadata.gz: f65eb6ce9b448598d8f54c2cae0301213f219f2086a39ed45a6149d8f997d3d6715e2cdf4bed273e6a54ef38d37bf642407085a92164da8063193aea14cba898
7
- data.tar.gz: 8ae0b1450b8a9ec2e7ae16a4f56bfa5299be0d9b072550c00782f4fb6f74ad8a3d075dec8721f6310d8e135d4a9c939b684068ec231341d4d00ba231c3a6edbb
6
+ metadata.gz: 3620a3921345db547e886a42fe143a38272b4d81575906e31a32ca5b984a3fb15e08239b1bf4b08a89e17c4fcc7c336b67b879616434657b38747f42c87a429b
7
+ data.tar.gz: 49cce94c651ba27b4ecfbb08e443fde71527fc159c34f58fab336344b361c94ec3d02439f325c3fd748cee960a52aab7d38ccef8b6a24d271dedf532f86762d9
data/ext/libuv/.mailmap CHANGED
@@ -10,10 +10,11 @@ Fedor Indutny <fedor.indutny@gmail.com> <fedor@indutny.com>
10
10
  Frank Denis <github@pureftpd.org>
11
11
  Isaac Z. Schlueter <i@izs.me>
12
12
  Justin Venus <justin.venus@gmail.com> <justin.venus@orbitz.com>
13
- Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
14
13
  Keno Fischer <kenof@stanford.edu> <kfischer+github@college.harvard.edu>
14
+ Keno Fischer <kenof@stanford.edu> <kfischer@college.harvard.edu>
15
15
  Maciej Małecki <maciej.malecki@notimplemented.org> <me@mmalecki.com>
16
16
  Marc Schlaich <marc.schlaich@googlemail.com> <marc.schlaich@gmail.com>
17
+ Rasmus Christian Pedersen <ruysch@outlook.com>
17
18
  Rasmus Pedersen <ruysch@outlook.com> <zerhacken@yahoo.com>
18
19
  Robert Mustacchi <rm@joyent.com> <rm@fingolfin.org>
19
20
  Ryan Dahl <ryan@joyent.com> <ry@tinyclouds.org>
data/ext/libuv/AUTHORS CHANGED
@@ -137,3 +137,5 @@ Javier Hernández <jhernandez@emergya.com>
137
137
  Tonis Tiigi <tonistiigi@gmail.com>
138
138
  Norio Kobota <nori.0428@gmail.com>
139
139
  李港平 <chopdown@gmail.com>
140
+ Chernyshev Viacheslav <astellar@ro.ru>
141
+ Stephen von Takach <steve@advancedcontrol.com.au>
@@ -142,11 +142,8 @@ Bug fixes and features should come with tests. Add your tests in the
142
142
  Look at other tests to see how they should be structured (license boilerplate,
143
143
  the way entry points are declared, etc.).
144
144
 
145
- ```
146
- $ make test
147
- ```
148
-
149
- Make sure that there are no test regressions.
145
+ Check README.md file to find out how to run the test suite and make sure that
146
+ there are no test regressions.
150
147
 
151
148
  ### PUSH
152
149
 
data/ext/libuv/ChangeLog CHANGED
@@ -1,3 +1,22 @@
1
+ 2014.05.02, Version 0.11.25 (Unstable), 2acd544cff7142e06aa3b09ec64b4a33dd9ab996
2
+
3
+ Changes since version 0.11.24:
4
+
5
+ * osx: pass const handle pointer to uv___stream_fd (Chernyshev Viacheslav)
6
+
7
+ * unix, windows: pass const handle ptr to uv_tcp_get*name (Chernyshev
8
+ Viacheslav)
9
+
10
+ * common: pass const sockaddr ptr to uv_ip*_name (Chernyshev Viacheslav)
11
+
12
+ * unix, windows: validate flags on uv_udp|tcp_bind (Saúl Ibarra Corretgé)
13
+
14
+ * unix: handle case when addr is not initialized after recvmsg (Saúl Ibarra
15
+ Corretgé)
16
+
17
+ * unix, windows: uv_now constness (Rasmus Pedersen)
18
+
19
+
1
20
  2014.04.15, Version 0.11.24 (Unstable), ed948c29f6e8c290f79325a6f0bc9ef35bcde644
2
21
 
3
22
  Changes since version 0.11.23:
@@ -13,7 +13,7 @@
13
13
  # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
14
 
15
15
  AC_PREREQ(2.57)
16
- AC_INIT([libuv], [0.11.25], [https://github.com/joyent/libuv/issues])
16
+ AC_INIT([libuv], [0.11.26], [https://github.com/joyent/libuv/issues])
17
17
  AC_CONFIG_MACRO_DIR([m4])
18
18
  m4_include([m4/libuv-extra-automake-flags.m4])
19
19
  m4_include([m4/as_case.m4])
@@ -31,6 +31,4 @@
31
31
 
32
32
  #define UV_HAVE_KQUEUE 1
33
33
 
34
- #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
35
-
36
34
  #endif /* UV_BSD_H */
@@ -58,6 +58,4 @@
58
58
 
59
59
  #define UV_HAVE_KQUEUE 1
60
60
 
61
- #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
62
-
63
61
  #endif /* UV_DARWIN_H */
@@ -31,6 +31,4 @@
31
31
  void* watchers[2]; \
32
32
  int wd; \
33
33
 
34
- #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
35
-
36
34
  #endif /* UV_LINUX_H */
@@ -41,6 +41,4 @@
41
41
 
42
42
  #endif /* defined(PORT_SOURCE_FILE) */
43
43
 
44
- #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
45
-
46
44
  #endif /* UV_SUNOS_H */
@@ -32,7 +32,7 @@
32
32
 
33
33
  #define UV_VERSION_MAJOR 0
34
34
  #define UV_VERSION_MINOR 11
35
- #define UV_VERSION_PATCH 25
35
+ #define UV_VERSION_PATCH 26
36
36
  #define UV_VERSION_IS_RELEASE 0
37
37
 
38
38
  #endif /* UV_VERSION_H */
@@ -587,4 +587,3 @@ int uv_utf16_to_utf8(const WCHAR* utf16Buffer, size_t utf16Size,
587
587
  int uv_utf8_to_utf16(const char* utf8Buffer, WCHAR* utf16Buffer,
588
588
  size_t utf16Size);
589
589
 
590
- #define UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
@@ -345,7 +345,7 @@ UV_EXTERN void uv_update_time(uv_loop_t*);
345
345
  *
346
346
  * Use uv_hrtime() if you need sub-millisecond granularity.
347
347
  */
348
- UV_EXTERN uint64_t uv_now(uv_loop_t*);
348
+ UV_EXTERN uint64_t uv_now(const uv_loop_t*);
349
349
 
350
350
  /*
351
351
  * Get backend file descriptor. Only kqueue, epoll and event ports are
@@ -874,8 +874,8 @@ typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
874
874
  * discard or repurpose the read buffer.
875
875
  * < 0 if a transmission error was detected.
876
876
  * buf uv_buf_t with the received data.
877
- * addr struct sockaddr_in or struct sockaddr_in6.
878
- * Valid for the duration of the callback only.
877
+ * addr struct sockaddr* containing the address of the sender.
878
+ * Can be NULL. Valid for the duration of the callback only.
879
879
  * flags One or more OR'ed UV_UDP_* constants.
880
880
  * Right now only UV_UDP_PARTIAL is used.
881
881
  */
@@ -2124,7 +2124,7 @@ UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
2124
2124
  /*
2125
2125
  * Returns the last uv_dlopen() or uv_dlsym() error message.
2126
2126
  */
2127
- UV_EXTERN const char* uv_dlerror(uv_lib_t* lib);
2127
+ UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib);
2128
2128
 
2129
2129
  /*
2130
2130
  * The mutex functions return 0 on success or an error code < 0
@@ -2204,8 +2204,14 @@ UV_EXTERN void uv_key_delete(uv_key_t* key);
2204
2204
  UV_EXTERN void* uv_key_get(uv_key_t* key);
2205
2205
  UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
2206
2206
 
2207
- UV_EXTERN int uv_thread_create(uv_thread_t *tid,
2208
- void (*entry)(void *arg), void *arg);
2207
+ /*
2208
+ * Callback that is invoked to initialize thread execution.
2209
+ *
2210
+ * `arg` is the same value that was passed to uv_thread_create().
2211
+ */
2212
+ typedef void (*uv_thread_cb)(void* arg);
2213
+
2214
+ UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
2209
2215
  UV_EXTERN unsigned long uv_thread_self(void);
2210
2216
  UV_EXTERN int uv_thread_join(uv_thread_t *tid);
2211
2217
 
@@ -231,7 +231,7 @@ int uv__async_start(uv_loop_t* loop, struct uv__async* wa, uv__async_cb cb) {
231
231
 
232
232
  snprintf(buf, sizeof(buf), "/proc/self/fd/%d", pipefd[0]);
233
233
  fd = uv__open_cloexec(buf, O_RDWR);
234
- if (fd != -1) {
234
+ if (fd >= 0) {
235
235
  uv__close(pipefd[0]);
236
236
  uv__close(pipefd[1]);
237
237
  pipefd[0] = fd;
@@ -59,7 +59,7 @@ int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) {
59
59
  }
60
60
 
61
61
 
62
- const char* uv_dlerror(uv_lib_t* lib) {
62
+ const char* uv_dlerror(const uv_lib_t* lib) {
63
63
  return lib->errmsg ? lib->errmsg : "no error";
64
64
  }
65
65
 
@@ -377,7 +377,7 @@ fallback:
377
377
 
378
378
  int uv_fs_event_stop(uv_fs_event_t* handle) {
379
379
  if (!uv__is_active(handle))
380
- return -EINVAL;
380
+ return 0;
381
381
 
382
382
  uv__handle_stop(handle);
383
383
 
@@ -231,7 +231,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
231
231
  struct watcher_list* w;
232
232
 
233
233
  if (!uv__is_active(handle))
234
- return -EINVAL;
234
+ return 0;
235
235
 
236
236
  w = find_watcher(handle->loop, handle->wd);
237
237
  assert(w != NULL);
@@ -444,6 +444,7 @@ void uv__stream_destroy(uv_stream_t* stream) {
444
444
  */
445
445
  static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) {
446
446
  int err;
447
+ int emfile_fd;
447
448
 
448
449
  if (loop->emfile_fd == -1)
449
450
  return -EMFILE;
@@ -457,7 +458,10 @@ static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) {
457
458
  uv__close(err);
458
459
  } while (err >= 0 || err == -EINTR);
459
460
 
460
- SAVE_ERRNO(loop->emfile_fd = uv__open_cloexec("/", O_RDONLY));
461
+ emfile_fd = uv__open_cloexec("/", O_RDONLY);
462
+ if (emfile_fd >= 0)
463
+ loop->emfile_fd = emfile_fd;
464
+
461
465
  return err;
462
466
  }
463
467
 
@@ -431,7 +431,7 @@ int uv_fs_event_start(uv_fs_event_t* handle,
431
431
 
432
432
  int uv_fs_event_stop(uv_fs_event_t* handle) {
433
433
  if (!uv__is_active(handle))
434
- return -EINVAL;
434
+ return 0;
435
435
 
436
436
  if (handle->fd == PORT_FIRED || handle->fd == PORT_LOADED) {
437
437
  port_dissociate(handle->loop->fs_fd,
@@ -221,16 +221,17 @@ static void uv__udp_recvmsg(uv_loop_t* loop,
221
221
  handle->recv_cb(handle, -errno, &buf, NULL, 0);
222
222
  }
223
223
  else {
224
- flags = 0;
224
+ const struct sockaddr *addr;
225
+ if (h.msg_namelen == 0)
226
+ addr = NULL;
227
+ else
228
+ addr = (const struct sockaddr*) &peer;
225
229
 
230
+ flags = 0;
226
231
  if (h.msg_flags & MSG_TRUNC)
227
232
  flags |= UV_UDP_PARTIAL;
228
233
 
229
- handle->recv_cb(handle,
230
- nread,
231
- &buf,
232
- (const struct sockaddr*) &peer,
233
- flags);
234
+ handle->recv_cb(handle, nread, &buf, addr, flags);
234
235
  }
235
236
  }
236
237
  /* recv_cb callback may decide to pause or close the handle */
@@ -319,9 +320,10 @@ int uv__udp_bind(uv_udp_t* handle,
319
320
 
320
321
  fd = handle->io_watcher.fd;
321
322
  if (fd == -1) {
322
- fd = uv__socket(addr->sa_family, SOCK_DGRAM, 0);
323
- if (fd == -1)
324
- return -errno;
323
+ err = uv__socket(addr->sa_family, SOCK_DGRAM, 0);
324
+ if (err < 0)
325
+ return err;
326
+ fd = err;
325
327
  handle->io_watcher.fd = fd;
326
328
  }
327
329
 
@@ -627,7 +629,6 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) {
627
629
  }
628
630
 
629
631
  int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) {
630
- int err;
631
632
  struct sockaddr_storage addr_st;
632
633
  struct sockaddr_in* addr4;
633
634
  struct sockaddr_in6* addr6;
@@ -653,9 +654,6 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
653
654
  }
654
655
 
655
656
  if (addr_st.ss_family == AF_INET) {
656
- err = uv__udp_maybe_deferred_bind(handle, AF_INET, UV_UDP_REUSEADDR);
657
- if (err)
658
- return err;
659
657
  if (setsockopt(handle->io_watcher.fd,
660
658
  IPPROTO_IP,
661
659
  IP_MULTICAST_IF,
@@ -664,9 +662,6 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
664
662
  return -errno;
665
663
  }
666
664
  } else if (addr_st.ss_family == AF_INET6) {
667
- err = uv__udp_maybe_deferred_bind(handle, AF_INET6, UV_UDP_REUSEADDR);
668
- if (err)
669
- return err;
670
665
  if (setsockopt(handle->io_watcher.fd,
671
666
  IPPROTO_IPV6,
672
667
  IPV6_MULTICAST_IF,
@@ -35,7 +35,7 @@
35
35
  #include <stdlib.h> /* malloc */
36
36
  #include <string.h> /* memset */
37
37
 
38
- #if defined(UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS) && !defined(_WIN32)
38
+ #if !defined(_WIN32)
39
39
  # include <net/if.h> /* if_nametoindex */
40
40
  #endif
41
41
 
@@ -107,17 +107,14 @@ int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) {
107
107
 
108
108
 
109
109
  int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) {
110
- #if defined(UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS)
111
110
  char address_part[40];
112
111
  size_t address_part_size;
113
112
  const char* zone_index;
114
- #endif
115
113
 
116
114
  memset(addr, 0, sizeof(*addr));
117
115
  addr->sin6_family = AF_INET6;
118
116
  addr->sin6_port = htons(port);
119
117
 
120
- #if defined(UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS)
121
118
  zone_index = strchr(ip, '%');
122
119
  if (zone_index != NULL) {
123
120
  address_part_size = zone_index - ip;
@@ -136,7 +133,6 @@ int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) {
136
133
  addr->sin6_scope_id = if_nametoindex(zone_index);
137
134
  #endif
138
135
  }
139
- #endif
140
136
 
141
137
  return uv_inet_pton(AF_INET6, ip, &addr->sin6_addr);
142
138
  }
@@ -384,7 +380,7 @@ void uv_stop(uv_loop_t* loop) {
384
380
  }
385
381
 
386
382
 
387
- uint64_t uv_now(uv_loop_t* loop) {
383
+ uint64_t uv_now(const uv_loop_t* loop) {
388
384
  return loop->time;
389
385
  }
390
386
 
@@ -64,7 +64,7 @@ int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) {
64
64
  }
65
65
 
66
66
 
67
- const char* uv_dlerror(uv_lib_t* lib) {
67
+ const char* uv_dlerror(const uv_lib_t* lib) {
68
68
  return lib->errmsg ? lib->errmsg : "no error";
69
69
  }
70
70
 
@@ -290,7 +290,7 @@ error:
290
290
 
291
291
  int uv_fs_event_stop(uv_fs_event_t* handle) {
292
292
  if (!uv__is_active(handle))
293
- return UV_EINVAL;
293
+ return 0;
294
294
 
295
295
  if (handle->dir_handle != INVALID_HANDLE_VALUE) {
296
296
  CloseHandle(handle->dir_handle);
@@ -115,7 +115,7 @@ static void uv_pipe_connection_init(uv_pipe_t* handle) {
115
115
  }
116
116
 
117
117
 
118
- static HANDLE open_named_pipe(WCHAR* name, DWORD* duplex_flags) {
118
+ static HANDLE open_named_pipe(const WCHAR* name, DWORD* duplex_flags) {
119
119
  HANDLE pipeHandle;
120
120
 
121
121
  /*
@@ -430,11 +430,10 @@ WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target) {
430
430
  int quote_hit;
431
431
  WCHAR* start;
432
432
 
433
- /*
434
- * Check if the string must be quoted;
435
- * if unnecessary, don't do it, it may only confuse older programs.
436
- */
437
433
  if (len == 0) {
434
+ /* Need double quotation for empty argument */
435
+ *(target++) = L'"';
436
+ *(target++) = L'"';
438
437
  return target;
439
438
  }
440
439
 
@@ -1117,6 +1117,14 @@ static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen,
1117
1117
  return 0;
1118
1118
  }
1119
1119
 
1120
+ #define FLIP_FGBG \
1121
+ do { \
1122
+ WORD fg = info.wAttributes & 0xF; \
1123
+ WORD bg = info.wAttributes & 0xF0; \
1124
+ info.wAttributes &= 0xFF00; \
1125
+ info.wAttributes |= fg << 4; \
1126
+ info.wAttributes |= bg >> 4; \
1127
+ } while (0)
1120
1128
 
1121
1129
  static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1122
1130
  unsigned short argc = handle->ansi_csi_argc;
@@ -1126,6 +1134,7 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1126
1134
 
1127
1135
  char fg_color = -1, bg_color = -1;
1128
1136
  char fg_bright = -1, bg_bright = -1;
1137
+ char inverse = -1;
1129
1138
 
1130
1139
  if (argc == 0) {
1131
1140
  /* Reset mode */
@@ -1133,6 +1142,7 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1133
1142
  bg_color = 0;
1134
1143
  fg_bright = 0;
1135
1144
  bg_bright = 0;
1145
+ inverse = 0;
1136
1146
  }
1137
1147
 
1138
1148
  for (i = 0; i < argc; i++) {
@@ -1144,6 +1154,7 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1144
1154
  bg_color = 0;
1145
1155
  fg_bright = 0;
1146
1156
  bg_bright = 0;
1157
+ inverse = 0;
1147
1158
 
1148
1159
  } else if (arg == 1) {
1149
1160
  /* Foreground bright on */
@@ -1158,6 +1169,10 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1158
1169
  /* Background bright on */
1159
1170
  bg_bright = 1;
1160
1171
 
1172
+ } else if (arg == 7) {
1173
+ /* Inverse: on */
1174
+ inverse = 1;
1175
+
1161
1176
  } else if (arg == 21 || arg == 22) {
1162
1177
  /* Foreground bright off */
1163
1178
  fg_bright = 0;
@@ -1166,6 +1181,10 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1166
1181
  /* Background bright off */
1167
1182
  bg_bright = 0;
1168
1183
 
1184
+ } else if (arg == 27) {
1185
+ /* Inverse: off */
1186
+ inverse = 0;
1187
+
1169
1188
  } else if (arg >= 30 && arg <= 37) {
1170
1189
  /* Set foreground color */
1171
1190
  fg_color = arg - 30;
@@ -1198,7 +1217,7 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1198
1217
  }
1199
1218
 
1200
1219
  if (fg_color == -1 && bg_color == -1 && fg_bright == -1 &&
1201
- bg_bright == -1) {
1220
+ bg_bright == -1 && inverse == -1) {
1202
1221
  /* Nothing changed */
1203
1222
  return 0;
1204
1223
  }
@@ -1208,6 +1227,10 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1208
1227
  return -1;
1209
1228
  }
1210
1229
 
1230
+ if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) {
1231
+ FLIP_FGBG;
1232
+ }
1233
+
1211
1234
  if (fg_color != -1) {
1212
1235
  info.wAttributes &= ~(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
1213
1236
  if (fg_color & 1) info.wAttributes |= FOREGROUND_RED;
@@ -1238,6 +1261,18 @@ static int uv_tty_set_style(uv_tty_t* handle, DWORD* error) {
1238
1261
  }
1239
1262
  }
1240
1263
 
1264
+ if (inverse != -1) {
1265
+ if (inverse) {
1266
+ info.wAttributes |= COMMON_LVB_REVERSE_VIDEO;
1267
+ } else {
1268
+ info.wAttributes &= ~COMMON_LVB_REVERSE_VIDEO;
1269
+ }
1270
+ }
1271
+
1272
+ if ((info.wAttributes & COMMON_LVB_REVERSE_VIDEO) > 0) {
1273
+ FLIP_FGBG;
1274
+ }
1275
+
1241
1276
  if (!SetConsoleTextAttribute(handle->handle, info.wAttributes)) {
1242
1277
  *error = GetLastError();
1243
1278
  return -1;
@@ -1316,6 +1351,25 @@ static int uv_tty_restore_state(uv_tty_t* handle,
1316
1351
  return 0;
1317
1352
  }
1318
1353
 
1354
+ static int uv_tty_set_cursor_visibility(uv_tty_t* handle,
1355
+ BOOL visible,
1356
+ DWORD* error) {
1357
+ CONSOLE_CURSOR_INFO cursor_info;
1358
+
1359
+ if (!GetConsoleCursorInfo(handle->handle, &cursor_info)) {
1360
+ *error = GetLastError();
1361
+ return -1;
1362
+ }
1363
+
1364
+ cursor_info.bVisible = visible;
1365
+
1366
+ if (!SetConsoleCursorInfo(handle->handle, &cursor_info)) {
1367
+ *error = GetLastError();
1368
+ return -1;
1369
+ }
1370
+
1371
+ return 0;
1372
+ }
1319
1373
 
1320
1374
  static int uv_tty_write_bufs(uv_tty_t* handle,
1321
1375
  const uv_buf_t bufs[],
@@ -1527,6 +1581,13 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
1527
1581
  continue;
1528
1582
  }
1529
1583
 
1584
+ } else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) &&
1585
+ handle->ansi_csi_argc == 0) {
1586
+ /* Ignores '?' if it is the first character after CSI[ */
1587
+ /* This is an extension character from the VT100 codeset */
1588
+ /* that is supported and used by most ANSI terminals today. */
1589
+ continue;
1590
+
1530
1591
  } else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' &&
1531
1592
  (handle->ansi_csi_argc > 0 || utf8_codepoint != '[')) {
1532
1593
  int x, y, d;
@@ -1629,6 +1690,24 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
1629
1690
  FLUSH_TEXT();
1630
1691
  uv_tty_restore_state(handle, 0, error);
1631
1692
  break;
1693
+
1694
+ case 'l':
1695
+ /* Hide the cursor */
1696
+ if (handle->ansi_csi_argc == 1 &&
1697
+ handle->ansi_csi_argv[0] == 25) {
1698
+ FLUSH_TEXT();
1699
+ uv_tty_set_cursor_visibility(handle, 0, error);
1700
+ }
1701
+ break;
1702
+
1703
+ case 'h':
1704
+ /* Show the cursor */
1705
+ if (handle->ansi_csi_argc == 1 &&
1706
+ handle->ansi_csi_argv[0] == 25) {
1707
+ FLUSH_TEXT();
1708
+ uv_tty_set_cursor_visibility(handle, 1, error);
1709
+ }
1710
+ break;
1632
1711
  }
1633
1712
 
1634
1713
  /* Sequence ended - go back to normal state. */
@@ -662,7 +662,6 @@ int uv_udp_set_membership(uv_udp_t* handle,
662
662
 
663
663
 
664
664
  int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr) {
665
- int err;
666
665
  struct sockaddr_storage addr_st;
667
666
  struct sockaddr_in* addr4;
668
667
  struct sockaddr_in6* addr6;
@@ -687,13 +686,10 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
687
686
  return UV_EINVAL;
688
687
  }
689
688
 
689
+ if (!(handle->flags & UV_HANDLE_BOUND))
690
+ return UV_EBADF;
691
+
690
692
  if (addr_st.ss_family == AF_INET) {
691
- err = uv_udp_maybe_bind(handle,
692
- (const struct sockaddr*) &uv_addr_ip4_any_,
693
- sizeof(uv_addr_ip4_any_),
694
- UV_UDP_REUSEADDR);
695
- if (err)
696
- return uv_translate_sys_error(err);
697
693
  if (setsockopt(handle->socket,
698
694
  IPPROTO_IP,
699
695
  IP_MULTICAST_IF,
@@ -702,12 +698,6 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
702
698
  return uv_translate_sys_error(WSAGetLastError());
703
699
  }
704
700
  } else if (addr_st.ss_family == AF_INET6) {
705
- err = uv_udp_maybe_bind(handle,
706
- (const struct sockaddr*) &uv_addr_ip6_any_,
707
- sizeof(uv_addr_ip6_any_),
708
- UV_UDP_REUSEADDR);
709
- if (err)
710
- return uv_translate_sys_error(err);
711
701
  if (setsockopt(handle->socket,
712
702
  IPPROTO_IPV6,
713
703
  IPV6_MULTICAST_IF,
@@ -726,15 +716,9 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
726
716
 
727
717
  int uv_udp_set_broadcast(uv_udp_t* handle, int value) {
728
718
  BOOL optval = (BOOL) value;
729
- int err;
730
719
 
731
- /* If the socket is unbound, bind to inaddr_any. */
732
- err = uv_udp_maybe_bind(handle,
733
- (const struct sockaddr*) &uv_addr_ip4_any_,
734
- sizeof(uv_addr_ip4_any_),
735
- 0);
736
- if (err)
737
- return uv_translate_sys_error(err);
720
+ if (!(handle->flags & UV_HANDLE_BOUND))
721
+ return UV_EBADF;
738
722
 
739
723
  if (setsockopt(handle->socket,
740
724
  SOL_SOCKET,
@@ -774,19 +758,13 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
774
758
  #define SOCKOPT_SETTER(name, option4, option6, validate) \
775
759
  int uv_udp_set_##name(uv_udp_t* handle, int value) { \
776
760
  DWORD optval = (DWORD) value; \
777
- int err; \
778
761
  \
779
762
  if (!(validate(value))) { \
780
763
  return UV_EINVAL; \
781
764
  } \
782
765
  \
783
- /* If the socket is unbound, bind to inaddr_any. */ \
784
- err = uv_udp_maybe_bind(handle, \
785
- (const struct sockaddr*) &uv_addr_ip4_any_, \
786
- sizeof(uv_addr_ip4_any_), \
787
- 0); \
788
- if (err) \
789
- return uv_translate_sys_error(err); \
766
+ if (!(handle->flags & UV_HANDLE_BOUND)) \
767
+ return UV_EBADF; \
790
768
  \
791
769
  if (!(handle->flags & UV_HANDLE_IPV6)) { \
792
770
  /* Set IPv4 socket option */ \
@@ -314,8 +314,7 @@ uint64_t uv_get_free_memory(void) {
314
314
  MEMORYSTATUSEX memory_status;
315
315
  memory_status.dwLength = sizeof(memory_status);
316
316
 
317
- if(!GlobalMemoryStatusEx(&memory_status))
318
- {
317
+ if (!GlobalMemoryStatusEx(&memory_status)) {
319
318
  return -1;
320
319
  }
321
320
 
@@ -327,8 +326,7 @@ uint64_t uv_get_total_memory(void) {
327
326
  MEMORYSTATUSEX memory_status;
328
327
  memory_status.dwLength = sizeof(memory_status);
329
328
 
330
- if(!GlobalMemoryStatusEx(&memory_status))
331
- {
329
+ if (!GlobalMemoryStatusEx(&memory_status)) {
332
330
  return -1;
333
331
  }
334
332
 
@@ -388,7 +386,7 @@ int uv_set_process_title(const char* title) {
388
386
  if (!length) {
389
387
  err = GetLastError();
390
388
  goto done;
391
- };
389
+ }
392
390
 
393
391
  /* If the title must be truncated insert a \0 terminator there */
394
392
  if (length > MAX_TITLE_LENGTH) {
@@ -51,24 +51,20 @@ static void after_write(uv_write_t* req, int status) {
51
51
  /* Free the read/write buffer and the request */
52
52
  wr = (write_req_t*) req;
53
53
  free(wr->buf.base);
54
- free(wr);
55
54
 
56
- if (status == 0)
55
+ if (status == 0) {
56
+ free(wr);
57
57
  return;
58
+ }
58
59
 
59
- fprintf(stderr, "uv_write error: %s\n", uv_strerror(status));
60
-
61
- if (status == UV_ECANCELED)
62
- return;
63
-
64
- ASSERT(status == UV_EPIPE);
65
- uv_close((uv_handle_t*)req->handle, on_close);
66
- }
67
-
60
+ fprintf(stderr,
61
+ "uv_write error: %s - %s\n",
62
+ uv_err_name(status),
63
+ uv_strerror(status));
68
64
 
69
- static void after_shutdown(uv_shutdown_t* req, int status) {
70
- uv_close((uv_handle_t*)req->handle, on_close);
71
- free(req);
65
+ if (!uv_is_closing((uv_handle_t*) req->handle))
66
+ uv_close((uv_handle_t*) req->handle, on_close);
67
+ free(wr);
72
68
  }
73
69
 
74
70
 
@@ -77,7 +73,6 @@ static void after_read(uv_stream_t* handle,
77
73
  const uv_buf_t* buf) {
78
74
  int i;
79
75
  write_req_t *wr;
80
- uv_shutdown_t* req;
81
76
 
82
77
  if (nread < 0) {
83
78
  /* Error or EOF */
@@ -87,9 +82,7 @@ static void after_read(uv_stream_t* handle,
87
82
  free(buf->base);
88
83
  }
89
84
 
90
- req = (uv_shutdown_t*) malloc(sizeof *req);
91
- uv_shutdown(req, handle, after_shutdown);
92
-
85
+ uv_close((uv_handle_t*) handle, on_close);
93
86
  return;
94
87
  }
95
88
 
@@ -32,7 +32,6 @@
32
32
 
33
33
 
34
34
  TEST_IMPL(ip6_addr_link_local) {
35
- #ifdef UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS
36
35
  char string_address[INET6_ADDRSTRLEN];
37
36
  uv_interface_address_t* addresses;
38
37
  uv_interface_address_t* address;
@@ -93,9 +92,6 @@ TEST_IMPL(ip6_addr_link_local) {
93
92
 
94
93
  MAKE_VALGRIND_HAPPY();
95
94
  return 0;
96
- #else
97
- RETURN_SKIP("Qualified link-local addresses are not supported.");
98
- #endif
99
95
  }
100
96
 
101
97
 
@@ -93,6 +93,7 @@ TEST_DECLARE (udp_dgram_too_big)
93
93
  TEST_DECLARE (udp_dual_stack)
94
94
  TEST_DECLARE (udp_ipv6_only)
95
95
  TEST_DECLARE (udp_options)
96
+ TEST_DECLARE (udp_no_autobind)
96
97
  TEST_DECLARE (udp_open)
97
98
  TEST_DECLARE (pipe_bind_error_addrinuse)
98
99
  TEST_DECLARE (pipe_bind_error_addrnotavail)
@@ -363,6 +364,7 @@ TASK_LIST_START
363
364
  TEST_ENTRY (udp_dual_stack)
364
365
  TEST_ENTRY (udp_ipv6_only)
365
366
  TEST_ENTRY (udp_options)
367
+ TEST_ENTRY (udp_no_autobind)
366
368
  TEST_ENTRY (udp_multicast_interface)
367
369
  TEST_ENTRY (udp_multicast_interface6)
368
370
  TEST_ENTRY (udp_multicast_join)
@@ -808,6 +808,7 @@ WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target);
808
808
 
809
809
  TEST_IMPL(argument_escaping) {
810
810
  const WCHAR* test_str[] = {
811
+ L"",
811
812
  L"HelloWorld",
812
813
  L"Hello World",
813
814
  L"Hello\"World",
@@ -86,3 +86,25 @@ TEST_IMPL(udp_options) {
86
86
  MAKE_VALGRIND_HAPPY();
87
87
  return 0;
88
88
  }
89
+
90
+
91
+ TEST_IMPL(udp_no_autobind) {
92
+ uv_loop_t* loop;
93
+ uv_udp_t h;
94
+
95
+ loop = uv_default_loop();
96
+
97
+ ASSERT(0 == uv_udp_init(loop, &h));
98
+ ASSERT(UV_EBADF == uv_udp_set_multicast_ttl(&h, 32));
99
+ ASSERT(UV_EBADF == uv_udp_set_broadcast(&h, 1));
100
+ ASSERT(UV_EBADF == uv_udp_set_ttl(&h, 1));
101
+ ASSERT(UV_EBADF == uv_udp_set_multicast_loop(&h, 1));
102
+ ASSERT(UV_EBADF == uv_udp_set_multicast_interface(&h, "0.0.0.0"));
103
+
104
+ uv_close((uv_handle_t*) &h, NULL);
105
+
106
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
107
+
108
+ MAKE_VALGRIND_HAPPY();
109
+ return 0;
110
+ }
data/lib/libuv/loop.rb CHANGED
@@ -51,13 +51,16 @@ module Libuv
51
51
 
52
52
  # Create an async call for scheduling work from other threads
53
53
  @run_queue = Queue.new
54
- @process_queue = Async.new @loop, method(:process_queue_cb)
54
+ @process_queue = @loop.async method(:process_queue_cb)
55
+ @process_queue.unref
55
56
 
56
57
  # Create a next tick timer
57
58
  @next_tick = @loop.timer method(:next_tick_cb)
59
+ @next_tick.unref
58
60
 
59
61
  # Create an async call for ending the loop
60
- @stop_loop = Async.new @loop, method(:stop_cb)
62
+ @stop_loop = @loop.async method(:stop_cb)
63
+ @stop_loop.unref
61
64
  end
62
65
 
63
66
 
@@ -73,6 +76,7 @@ module Libuv
73
76
 
74
77
  def next_tick_cb
75
78
  @next_tick_scheduled = false
79
+ @next_tick.unref
76
80
  process_queue_cb
77
81
  end
78
82
 
@@ -380,6 +384,7 @@ module Libuv
380
384
  if not @next_tick_scheduled
381
385
  @next_tick.start(0)
382
386
  @next_tick_scheduled = true
387
+ @next_tick.ref
383
388
  end
384
389
  else
385
390
  @process_queue.call
data/lib/libuv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Libuv
2
- VERSION = '0.12.4'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libuv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bulat Shakirzyanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-23 00:00:00.000000000 Z
12
+ date: 2014-05-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -434,7 +434,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
434
  version: '0'
435
435
  requirements: []
436
436
  rubyforge_project:
437
- rubygems_version: 2.0.3
437
+ rubygems_version: 2.1.11
438
438
  signing_key:
439
439
  specification_version: 4
440
440
  summary: libuv bindings for Ruby