libuv 1.0.2 → 1.0.3

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: d13aec5db12ee41ad8e672bda901a128d7e29fd3
4
- data.tar.gz: 554f2bd2a9ff1d9a69af2551a48a944e3af5cd91
3
+ metadata.gz: 761d4fa5d96a80530d0b0edd0cb39b8495f81535
4
+ data.tar.gz: e5e2f17be5d237f0ac49f5973ef4f21a8cb33fe6
5
5
  SHA512:
6
- metadata.gz: f8362798abe6237ea412ff7ff03fbfa27a47d3606e1f8e318ae8f33555c7e23b59e8f3c84f1ab8453b08464b69cfc1fc568a5127bcc13718f02fd5fc7cb78bf6
7
- data.tar.gz: 7f82bc4fff20b9f0a380d3bfe76b2790b5d602679f0943cbe50835bba88a5988f09c7fab31e04d2cd43bc268e2aeec8c8cbcab626ef2a3a451c3fd2e530fbc66
6
+ metadata.gz: 7d64a84900c157f15e2ede04a848ce9ca961145bd961635dc0db125a82cd10e6448a0fa25bc0c12f9b530053f919eed7aeb95bcc99cbea75981b0f11dd16f8e1
7
+ data.tar.gz: 8164ddfc3a957a5cbb99f8428bb89159fde23fbee6b1c6398b6ebefd90a9e7b0f232c0eab6453da5afdf91b75b364a742a05b86e780ed44f0815a69abb66abfd
data/.travis.yml CHANGED
@@ -3,14 +3,14 @@ rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
5
  - ruby-head
6
- - rbx-2.2.1
7
- - jruby-head
6
+ - rbx-2
7
+ - jruby-19mode
8
8
  branches:
9
9
  only:
10
10
  - master
11
11
  before_install:
12
12
  - sudo apt-get install subversion
13
13
  - git submodule update --init --recursive
14
- - echo "yes" | gem uninstall ffi -a
14
+ - gem install ffi
15
15
  before_script:
16
16
  - rake compile
@@ -1892,7 +1892,7 @@ UV_EXTERN int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file,
1892
1892
  UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
1893
1893
  int mode, uv_fs_cb cb);
1894
1894
 
1895
- UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* template,
1895
+ UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl,
1896
1896
  uv_fs_cb cb);
1897
1897
 
1898
1898
  UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path,
@@ -1009,10 +1009,10 @@ int uv_fs_mkdir(uv_loop_t* loop,
1009
1009
 
1010
1010
  int uv_fs_mkdtemp(uv_loop_t* loop,
1011
1011
  uv_fs_t* req,
1012
- const char* template,
1012
+ const char* tpl,
1013
1013
  uv_fs_cb cb) {
1014
1014
  INIT(MKDTEMP);
1015
- req->path = strdup(template);
1015
+ req->path = strdup(tpl);
1016
1016
  if (req->path == NULL)
1017
1017
  return -ENOMEM;
1018
1018
  POST;
@@ -45,8 +45,9 @@ static uv_once_t uv_default_loop_init_guard_ = UV_ONCE_INIT;
45
45
 
46
46
 
47
47
  #if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR))
48
- /* Our crt debug report handler allows us to temporarily disable asserts */
49
- /* just for the current thread. */
48
+ /* Our crt debug report handler allows us to temporarily disable asserts
49
+ * just for the current thread.
50
+ */
50
51
 
51
52
  UV_THREAD_LOCAL int uv__crt_assert_enabled = TRUE;
52
53
 
@@ -55,8 +56,9 @@ static int uv__crt_dbg_report_handler(int report_type, char *message, int *ret_v
55
56
  return FALSE;
56
57
 
57
58
  if (ret_val) {
58
- /* Set ret_val to 0 to continue with normal execution. */
59
- /* Set ret_val to 1 to trigger a breakpoint. */
59
+ /* Set ret_val to 0 to continue with normal execution.
60
+ * Set ret_val to 1 to trigger a breakpoint.
61
+ */
60
62
 
61
63
  if(IsDebuggerPresent())
62
64
  *ret_val = 1;
@@ -86,21 +88,24 @@ static void uv_init(void) {
86
88
  SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
87
89
  SEM_NOOPENFILEERRORBOX);
88
90
 
89
- /* Tell the CRT to not exit the application when an invalid parameter is */
90
- /* passed. The main issue is that invalid FDs will trigger this behavior. */
91
+ /* Tell the CRT to not exit the application when an invalid parameter is
92
+ * passed. The main issue is that invalid FDs will trigger this behavior.
93
+ */
91
94
  #if !defined(__MINGW32__) || __MSVCRT_VERSION__ >= 0x800
92
95
  _set_invalid_parameter_handler(uv__crt_invalid_parameter_handler);
93
96
  #endif
94
97
 
95
- /* We also need to setup our debug report handler because some CRT */
96
- /* functions (eg _get_osfhandle) raise an assert when called with invalid */
97
- /* FDs even though they return the proper error code in the release build. */
98
+ /* We also need to setup our debug report handler because some CRT
99
+ * functions (eg _get_osfhandle) raise an assert when called with invalid
100
+ * FDs even though they return the proper error code in the release build.
101
+ */
98
102
  #if defined(_DEBUG) && (defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR))
99
103
  _CrtSetReportHook(uv__crt_dbg_report_handler);
100
104
  #endif
101
105
 
102
- /* Fetch winapi function pointers. This must be done first because other */
103
- /* intialization code might need these function pointers to be loaded. */
106
+ /* Fetch winapi function pointers. This must be done first because other
107
+ * intialization code might need these function pointers to be loaded.
108
+ */
104
109
  uv_winapi_init();
105
110
 
106
111
  /* Initialize winsock */
@@ -129,8 +134,9 @@ int uv_loop_init(uv_loop_t* loop) {
129
134
  if (loop->iocp == NULL)
130
135
  return uv_translate_sys_error(GetLastError());
131
136
 
132
- /* To prevent uninitialized memory access, loop->time must be intialized */
133
- /* to zero before calling uv_update_time for the first time. */
137
+ /* To prevent uninitialized memory access, loop->time must be intialized
138
+ * to zero before calling uv_update_time for the first time.
139
+ */
134
140
  loop->time = 0;
135
141
  loop->last_tick_count = 0;
136
142
  uv_update_time(loop);
@@ -272,22 +278,31 @@ int uv_backend_fd(const uv_loop_t* loop) {
272
278
 
273
279
 
274
280
  int uv_backend_timeout(const uv_loop_t* loop) {
275
- return 0;
281
+ if (loop->stop_flag != 0)
282
+ return 0;
283
+
284
+ if (!uv__has_active_handles(loop) && !uv__has_active_reqs(loop))
285
+ return 0;
286
+
287
+ if (loop->pending_reqs_tail)
288
+ return 0;
289
+
290
+ if (loop->endgame_handles)
291
+ return 0;
292
+
293
+ if (loop->idle_handles)
294
+ return 0;
295
+
296
+ return uv__next_timeout(loop);
276
297
  }
277
298
 
278
299
 
279
- static void uv_poll(uv_loop_t* loop, int block) {
280
- DWORD bytes, timeout;
300
+ static void uv_poll(uv_loop_t* loop, DWORD timeout) {
301
+ DWORD bytes;
281
302
  ULONG_PTR key;
282
303
  OVERLAPPED* overlapped;
283
304
  uv_req_t* req;
284
305
 
285
- if (block) {
286
- timeout = uv_get_poll_timeout(loop);
287
- } else {
288
- timeout = 0;
289
- }
290
-
291
306
  GetQueuedCompletionStatus(loop->iocp,
292
307
  &bytes,
293
308
  &key,
@@ -302,28 +317,22 @@ static void uv_poll(uv_loop_t* loop, int block) {
302
317
  /* Serious error */
303
318
  uv_fatal_error(GetLastError(), "GetQueuedCompletionStatus");
304
319
  } else {
305
- /* We're sure that at least `timeout` milliseconds have expired, but */
306
- /* this may not be reflected yet in the GetTickCount() return value. */
307
- /* Therefore we ensure it's taken into account here. */
320
+ /* We're sure that at least `timeout` milliseconds have expired, but
321
+ * this may not be reflected yet in the GetTickCount() return value.
322
+ * Therefore we ensure it's taken into account here.
323
+ */
308
324
  uv__time_forward(loop, timeout);
309
325
  }
310
326
  }
311
327
 
312
328
 
313
- static void uv_poll_ex(uv_loop_t* loop, int block) {
329
+ static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) {
314
330
  BOOL success;
315
- DWORD timeout;
316
331
  uv_req_t* req;
317
332
  OVERLAPPED_ENTRY overlappeds[128];
318
333
  ULONG count;
319
334
  ULONG i;
320
335
 
321
- if (block) {
322
- timeout = uv_get_poll_timeout(loop);
323
- } else {
324
- timeout = 0;
325
- }
326
-
327
336
  success = pGetQueuedCompletionStatusEx(loop->iocp,
328
337
  overlappeds,
329
338
  ARRAY_SIZE(overlappeds),
@@ -341,9 +350,10 @@ static void uv_poll_ex(uv_loop_t* loop, int block) {
341
350
  /* Serious error */
342
351
  uv_fatal_error(GetLastError(), "GetQueuedCompletionStatusEx");
343
352
  } else if (timeout > 0) {
344
- /* We're sure that at least `timeout` milliseconds have expired, but */
345
- /* this may not be reflected yet in the GetTickCount() return value. */
346
- /* Therefore we ensure it's taken into account here. */
353
+ /* We're sure that at least `timeout` milliseconds have expired, but
354
+ * this may not be reflected yet in the GetTickCount() return value.
355
+ * Therefore we ensure it's taken into account here.
356
+ */
347
357
  uv__time_forward(loop, timeout);
348
358
  }
349
359
  }
@@ -362,8 +372,9 @@ int uv_loop_alive(const uv_loop_t* loop) {
362
372
 
363
373
 
364
374
  int uv_run(uv_loop_t *loop, uv_run_mode mode) {
375
+ DWORD timeout;
365
376
  int r;
366
- void (*poll)(uv_loop_t* loop, int block);
377
+ void (*poll)(uv_loop_t* loop, DWORD timeout);
367
378
 
368
379
  if (pGetQueuedCompletionStatusEx)
369
380
  poll = &uv_poll_ex;
@@ -382,13 +393,11 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
382
393
  uv_idle_invoke(loop);
383
394
  uv_prepare_invoke(loop);
384
395
 
385
- (*poll)(loop, loop->idle_handles == NULL &&
386
- loop->pending_reqs_tail == NULL &&
387
- loop->endgame_handles == NULL &&
388
- !loop->stop_flag &&
389
- (loop->active_handles > 0 ||
390
- !QUEUE_EMPTY(&loop->active_reqs)) &&
391
- !(mode & UV_RUN_NOWAIT));
396
+ timeout = 0;
397
+ if ((mode & UV_RUN_NOWAIT) == 0)
398
+ timeout = uv_backend_timeout(loop);
399
+
400
+ (*poll)(loop, timeout);
392
401
 
393
402
  uv_check_invoke(loop);
394
403
  uv_process_endgames(loop);
@@ -1797,13 +1797,13 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
1797
1797
  }
1798
1798
 
1799
1799
 
1800
- int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* template,
1800
+ int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl,
1801
1801
  uv_fs_cb cb) {
1802
1802
  int err;
1803
1803
 
1804
1804
  uv_fs_req_init(loop, req, UV_FS_MKDTEMP, cb);
1805
1805
 
1806
- err = fs__capture_path(loop, req, template, NULL, TRUE);
1806
+ err = fs__capture_path(loop, req, tpl, NULL, TRUE);
1807
1807
  if (err)
1808
1808
  return uv_translate_sys_error(err);
1809
1809
 
@@ -49,9 +49,9 @@ static void uv__getnameinfo_work(struct uv__work* w) {
49
49
  ret = GetNameInfoW((struct sockaddr*)&req->storage,
50
50
  sizeof(req->storage),
51
51
  host,
52
- sizeof(host),
52
+ ARRAY_SIZE(host),
53
53
  service,
54
- sizeof(service),
54
+ ARRAY_SIZE(service),
55
55
  req->flags);
56
56
  req->retcode = uv__getaddrinfo_translate_error(ret);
57
57
 
@@ -239,7 +239,7 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle);
239
239
  */
240
240
  void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle);
241
241
 
242
- DWORD uv_get_poll_timeout(uv_loop_t* loop);
242
+ DWORD uv__next_timeout(const uv_loop_t* loop);
243
243
  void uv__time_forward(uv_loop_t* loop, uint64_t msecs);
244
244
  void uv_process_timers(uv_loop_t* loop);
245
245
 
@@ -813,6 +813,20 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
813
813
  return 0;
814
814
  }
815
815
 
816
+ /*
817
+ * Attempt to find the value of the PATH environment variable in the child's
818
+ * preprocessed environment.
819
+ *
820
+ * If found, a pointer into `env` is returned. If not found, NULL is returned.
821
+ */
822
+ static WCHAR* find_path(WCHAR *env) {
823
+ for (; env != NULL && *env != 0; env += wcslen(env) + 1) {
824
+ if (wcsncmp(env, L"PATH=", 5) == 0)
825
+ return &env[5];
826
+ }
827
+
828
+ return NULL;
829
+ }
816
830
 
817
831
  /*
818
832
  * Called on Windows thread-pool thread to indicate that
@@ -910,7 +924,7 @@ int uv_spawn(uv_loop_t* loop,
910
924
  const uv_process_options_t* options) {
911
925
  int i;
912
926
  int err = 0;
913
- WCHAR* path = NULL;
927
+ WCHAR* path = NULL, *alloc_path = NULL;
914
928
  BOOL result;
915
929
  WCHAR* application_path = NULL, *application = NULL, *arguments = NULL,
916
930
  *env = NULL, *cwd = NULL;
@@ -984,7 +998,8 @@ int uv_spawn(uv_loop_t* loop,
984
998
  }
985
999
 
986
1000
  /* Get PATH environment variable. */
987
- {
1001
+ path = find_path(env);
1002
+ if (path == NULL) {
988
1003
  DWORD path_len, r;
989
1004
 
990
1005
  path_len = GetEnvironmentVariableW(L"PATH", NULL, 0);
@@ -993,11 +1008,12 @@ int uv_spawn(uv_loop_t* loop,
993
1008
  goto done;
994
1009
  }
995
1010
 
996
- path = (WCHAR*) malloc(path_len * sizeof(WCHAR));
997
- if (path == NULL) {
1011
+ alloc_path = (WCHAR*) malloc(path_len * sizeof(WCHAR));
1012
+ if (alloc_path == NULL) {
998
1013
  err = ERROR_OUTOFMEMORY;
999
1014
  goto done;
1000
1015
  }
1016
+ path = alloc_path;
1001
1017
 
1002
1018
  r = GetEnvironmentVariableW(L"PATH", path, path_len);
1003
1019
  if (r == 0 || r >= path_len) {
@@ -1131,7 +1147,7 @@ int uv_spawn(uv_loop_t* loop,
1131
1147
  free(arguments);
1132
1148
  free(cwd);
1133
1149
  free(env);
1134
- free(path);
1150
+ free(alloc_path);
1135
1151
 
1136
1152
  if (process->child_stdio_buffer != NULL) {
1137
1153
  /* Clean up child stdio handles. */
@@ -36,10 +36,11 @@ void uv_update_time(uv_loop_t* loop) {
36
36
 
37
37
  time.QuadPart = loop->time;
38
38
 
39
- /* GetTickCount() can conceivably wrap around, so when the current tick */
40
- /* count is lower than the last tick count, we'll assume it has wrapped. */
41
- /* uv_poll must make sure that the timer can never overflow more than */
42
- /* once between two subsequent uv_update_time calls. */
39
+ /* GetTickCount() can conceivably wrap around, so when the current tick
40
+ * count is lower than the last tick count, we'll assume it has wrapped.
41
+ * uv_poll must make sure that the timer can never overflow more than
42
+ * once between two subsequent uv_update_time calls.
43
+ */
43
44
  time.LowPart = ticks;
44
45
  if (ticks < loop->last_tick_count)
45
46
  time.HighPart++;
@@ -47,13 +48,14 @@ void uv_update_time(uv_loop_t* loop) {
47
48
  /* Remember the last tick count. */
48
49
  loop->last_tick_count = ticks;
49
50
 
50
- /* The GetTickCount() resolution isn't too good. Sometimes it'll happen */
51
- /* that GetQueuedCompletionStatus() or GetQueuedCompletionStatusEx() has */
52
- /* waited for a couple of ms but this is not reflected in the GetTickCount */
53
- /* result yet. Therefore whenever GetQueuedCompletionStatus times out */
54
- /* we'll add the number of ms that it has waited to the current loop time. */
55
- /* When that happened the loop time might be a little ms farther than what */
56
- /* we've just computed, and we shouldn't update the loop time. */
51
+ /* The GetTickCount() resolution isn't too good. Sometimes it'll happen
52
+ * that GetQueuedCompletionStatus() or GetQueuedCompletionStatusEx() has
53
+ * waited for a couple of ms but this is not reflected in the GetTickCount
54
+ * result yet. Therefore whenever GetQueuedCompletionStatus times out
55
+ * we'll add the number of ms that it has waited to the current loop time.
56
+ * When that happened the loop time might be a little ms farther than what
57
+ * we've just computed, and we shouldn't update the loop time.
58
+ */
57
59
  if (loop->time < time.QuadPart)
58
60
  loop->time = time.QuadPart;
59
61
  }
@@ -193,24 +195,26 @@ uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
193
195
  }
194
196
 
195
197
 
196
- DWORD uv_get_poll_timeout(uv_loop_t* loop) {
198
+ DWORD uv__next_timeout(const uv_loop_t* loop) {
197
199
  uv_timer_t* timer;
198
200
  int64_t delta;
199
201
 
200
- /* Check if there are any running timers */
201
- timer = RB_MIN(uv_timer_tree_s, &loop->timers);
202
+ /* Check if there are any running timers
203
+ * Need to cast away const first, since RB_MIN doesn't know what we are
204
+ * going to do with this return value, it can't be marked const
205
+ */
206
+ timer = RB_MIN(uv_timer_tree_s, &((uv_loop_t*)loop)->timers);
202
207
  if (timer) {
203
- uv_update_time(loop);
204
-
205
208
  delta = timer->due - loop->time;
206
209
  if (delta >= UINT_MAX >> 1) {
207
- /* A timeout value of UINT_MAX means infinite, so that's no good. But */
208
- /* more importantly, there's always the risk that GetTickCount wraps. */
209
- /* uv_update_time can detect this, but we must make sure that the */
210
- /* tick counter never overflows twice between two subsequent */
211
- /* uv_update_time calls. We do this by never sleeping more than half */
212
- /* the time it takes to wrap the counter - which is huge overkill, */
213
- /* but hey, it's not so bad to wake up every 25 days. */
210
+ /* A timeout value of UINT_MAX means infinite, so that's no good. But
211
+ * more importantly, there's always the risk that GetTickCount wraps.
212
+ * uv_update_time can detect this, but we must make sure that the
213
+ * tick counter never overflows twice between two subsequent
214
+ * uv_update_time calls. We do this by never sleeping more than half
215
+ * the time it takes to wrap the counter - which is huge overkill,
216
+ * but hey, it's not so bad to wake up every 25 days.
217
+ */
214
218
  return UINT_MAX >> 1;
215
219
  } else if (delta < 0) {
216
220
  /* Negative timeout values are not allowed */
@@ -28,6 +28,7 @@ TEST_DECLARE (loop_alive)
28
28
  TEST_DECLARE (loop_close)
29
29
  TEST_DECLARE (loop_stop)
30
30
  TEST_DECLARE (loop_update_time)
31
+ TEST_DECLARE (loop_backend_timeout)
31
32
  TEST_DECLARE (barrier_1)
32
33
  TEST_DECLARE (barrier_2)
33
34
  TEST_DECLARE (barrier_3)
@@ -72,7 +73,9 @@ TEST_DECLARE (tcp_connect_error_fault)
72
73
  TEST_DECLARE (tcp_connect_timeout)
73
74
  TEST_DECLARE (tcp_close_while_connecting)
74
75
  TEST_DECLARE (tcp_close)
76
+ #ifndef _WIN32
75
77
  TEST_DECLARE (tcp_close_accept)
78
+ #endif
76
79
  TEST_DECLARE (tcp_flags)
77
80
  TEST_DECLARE (tcp_write_to_half_open_connection)
78
81
  TEST_DECLARE (tcp_unexpected_read)
@@ -189,6 +192,7 @@ TEST_DECLARE (spawn_stdout_to_file)
189
192
  TEST_DECLARE (spawn_stdout_and_stderr_to_file)
190
193
  TEST_DECLARE (spawn_auto_unref)
191
194
  TEST_DECLARE (spawn_closed_process_io)
195
+ TEST_DECLARE (spawn_reads_child_path)
192
196
  TEST_DECLARE (fs_poll)
193
197
  TEST_DECLARE (fs_poll_getpath)
194
198
  TEST_DECLARE (kill)
@@ -291,6 +295,7 @@ TASK_LIST_START
291
295
  TEST_ENTRY (loop_close)
292
296
  TEST_ENTRY (loop_stop)
293
297
  TEST_ENTRY (loop_update_time)
298
+ TEST_ENTRY (loop_backend_timeout)
294
299
  TEST_ENTRY (barrier_1)
295
300
  TEST_ENTRY (barrier_2)
296
301
  TEST_ENTRY (barrier_3)
@@ -356,7 +361,9 @@ TASK_LIST_START
356
361
  TEST_ENTRY (tcp_connect_timeout)
357
362
  TEST_ENTRY (tcp_close_while_connecting)
358
363
  TEST_ENTRY (tcp_close)
364
+ #ifndef _WIN32
359
365
  TEST_ENTRY (tcp_close_accept)
366
+ #endif
360
367
  TEST_ENTRY (tcp_flags)
361
368
  TEST_ENTRY (tcp_write_to_half_open_connection)
362
369
  TEST_ENTRY (tcp_unexpected_read)
@@ -514,6 +521,7 @@ TASK_LIST_START
514
521
  TEST_ENTRY (spawn_stdout_and_stderr_to_file)
515
522
  TEST_ENTRY (spawn_auto_unref)
516
523
  TEST_ENTRY (spawn_closed_process_io)
524
+ TEST_ENTRY (spawn_reads_child_path)
517
525
  TEST_ENTRY (fs_poll)
518
526
  TEST_ENTRY (fs_poll_getpath)
519
527
  TEST_ENTRY (kill)
@@ -30,5 +30,34 @@ TEST_IMPL(loop_update_time) {
30
30
  while (uv_now(uv_default_loop()) - start < 1000)
31
31
  ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_NOWAIT));
32
32
 
33
+ MAKE_VALGRIND_HAPPY();
34
+ return 0;
35
+ }
36
+
37
+ static void cb(uv_timer_t* timer) {
38
+ uv_close((uv_handle_t*)timer, NULL);
39
+ }
40
+
41
+ TEST_IMPL(loop_backend_timeout) {
42
+ uv_loop_t *loop = uv_default_loop();
43
+ uv_timer_t timer;
44
+ int r;
45
+
46
+ r = uv_timer_init(loop, &timer);
47
+ ASSERT(r == 0);
48
+
49
+ ASSERT(!uv_loop_alive(loop));
50
+ ASSERT(uv_backend_timeout(loop) == 0);
51
+
52
+ r = uv_timer_start(&timer, cb, 1000, 0); /* 1 sec */
53
+ ASSERT(r == 0);
54
+ ASSERT(uv_backend_timeout(loop) > 100); /* 0.1 sec */
55
+ ASSERT(uv_backend_timeout(loop) <= 1000); /* 1 sec */
56
+
57
+ r = uv_run(loop, UV_RUN_DEFAULT);
58
+ ASSERT(r == 0);
59
+ ASSERT(uv_backend_timeout(loop) == 0);
60
+
61
+ MAKE_VALGRIND_HAPPY();
33
62
  return 0;
34
63
  }
@@ -1291,3 +1291,38 @@ TEST_IMPL(closed_fd_events) {
1291
1291
  return 0;
1292
1292
  }
1293
1293
  #endif /* !_WIN32 */
1294
+
1295
+ TEST_IMPL(spawn_reads_child_path) {
1296
+ int r;
1297
+ int len;
1298
+ char path[1024];
1299
+ char *env[2] = {path, NULL};
1300
+
1301
+ /* Set up the process, but make sure that the file to run is relative and */
1302
+ /* requires a lookup into PATH */
1303
+ init_process_options("spawn_helper1", exit_cb);
1304
+ options.file = "run-tests";
1305
+ args[0] = "run-tests";
1306
+
1307
+ /* Set up the PATH env variable */
1308
+ for (len = strlen(exepath);
1309
+ exepath[len - 1] != '/' && exepath[len - 1] != '\\';
1310
+ len--);
1311
+ exepath[len] = 0;
1312
+ strcpy(path, "PATH=");
1313
+ strcpy(path + 5, exepath);
1314
+
1315
+ options.env = env;
1316
+
1317
+ r = uv_spawn(uv_default_loop(), &process, &options);
1318
+ ASSERT(r == 0);
1319
+
1320
+ r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
1321
+ ASSERT(r == 0);
1322
+
1323
+ ASSERT(exit_cb_called == 1);
1324
+ ASSERT(close_cb_called == 1);
1325
+
1326
+ MAKE_VALGRIND_HAPPY();
1327
+ return 0;
1328
+ }
@@ -19,6 +19,9 @@
19
19
  * IN THE SOFTWARE.
20
20
  */
21
21
 
22
+ /* this test is Unix only */
23
+ #ifndef _WIN32
24
+
22
25
  #include "uv.h"
23
26
  #include "task.h"
24
27
 
@@ -181,3 +184,5 @@ TEST_IMPL(tcp_close_accept) {
181
184
  MAKE_VALGRIND_HAPPY();
182
185
  return 0;
183
186
  }
187
+
188
+ #endif /* !_WIN32 */
@@ -9,6 +9,42 @@ module Libuv
9
9
  :int32, :st_qspare_0, :int64, :st_qspare_1, :int64
10
10
  end
11
11
 
12
+ class Sockaddr < FFI::Struct
13
+ layout :sa_len, :uint8,
14
+ :sa_family, :sa_family_t,
15
+ :sa_data, [:char, 14]
16
+ end
17
+
18
+ class InAddr < FFI::Struct
19
+ layout :s_addr, :in_addr_t
20
+ end
21
+
22
+ class SockaddrIn < FFI::Struct
23
+ layout :sin_len, :uint8,
24
+ :sin_family, :sa_family_t,
25
+ :sin_port, :in_port_t,
26
+ :sin_addr, InAddr,
27
+ :sin_zero, [:char, 8]
28
+ end
29
+
30
+ class U6Addr < FFI::Union
31
+ layout :__u6_addr8, [:uint8, 16],
32
+ :__u6_addr16, [:uint16, 8]
33
+ end
34
+
35
+ class In6Addr < FFI::Struct
36
+ layout :__u6_addr, U6Addr
37
+ end
38
+
39
+ class SockaddrIn6 < FFI::Struct
40
+ layout :sin6_len, :uint8,
41
+ :sin6_family, :sa_family_t,
42
+ :sin6_port, :in_port_t,
43
+ :sin6_flowinfo, :uint32,
44
+ :sin6_addr, In6Addr,
45
+ :sin6_scope_id, :uint32
46
+ end
47
+
12
48
  class UvAddrinfo < FFI::Struct
13
49
  layout :flags, :int,
14
50
  :family, :int,
@@ -4,5 +4,50 @@ module Libuv
4
4
  typedef :long, :blksize_t
5
5
  typedef :uint32, :in_addr_t
6
6
  typedef :ushort, :in_port_t
7
+
8
+
9
+ class Sockaddr < FFI::Struct
10
+ layout :sa_family, :sa_family_t,
11
+ :sa_data, [:char, 14]
12
+ end
13
+
14
+ class InAddr < FFI::Struct
15
+ layout :s_addr, :in_addr_t
16
+ end
17
+
18
+ class SockaddrIn < FFI::Struct
19
+ layout :sin_family, :sa_family_t,
20
+ :sin_port, :in_port_t,
21
+ :sin_addr, InAddr,
22
+ :sin_zero, [:char, 8]
23
+ end
24
+
25
+ class U6Addr < FFI::Union
26
+ layout :__u6_addr8, [:uint8, 16],
27
+ :__u6_addr16, [:uint16, 8]
28
+ end
29
+
30
+ class In6Addr < FFI::Struct
31
+ layout :__u6_addr, U6Addr
32
+ end
33
+
34
+ class SockaddrIn6 < FFI::Struct
35
+ layout :sin6_family, :sa_family_t,
36
+ :sin6_port, :in_port_t,
37
+ :sin6_flowinfo, :uint32,
38
+ :sin6_addr, In6Addr,
39
+ :sin6_scope_id, :uint32
40
+ end
41
+
42
+ class UvAddrinfo < FFI::Struct
43
+ layout :flags, :int,
44
+ :family, :int,
45
+ :socktype, :int,
46
+ :protocol, :int,
47
+ :addrlen, :socklen_t,
48
+ :addr, Sockaddr.by_ref,
49
+ :canonname, :string,
50
+ :next, UvAddrinfo.by_ref
51
+ end
7
52
  end
8
53
  end
@@ -13,17 +13,6 @@ module Libuv
13
13
  :st_mtime, :time_t, :st_ctime, :time_t
14
14
  end
15
15
 
16
- class UvAddrinfo < FFI::Struct
17
- layout :flags, :int,
18
- :family, :int,
19
- :socktype, :int,
20
- :protocol, :int,
21
- :addrlen, :socklen_t,
22
- :addr, Sockaddr.by_ref,
23
- :canonname, :string,
24
- :next, UvAddrinfo.by_ref
25
- end
26
-
27
16
  attach_function :ntohs, [:ushort], :ushort, :blocking => true
28
17
  end
29
18
  end
@@ -26,6 +26,46 @@ module Libuv
26
26
  :st_rdev, :dev_t, :st_size, :off_t, :st_uid, :uid_t
27
27
  end
28
28
 
29
+
30
+
31
+ class Sockaddr < FFI::Struct
32
+ layout :sa_len, :uint8,
33
+ :sa_family, :sa_family_t,
34
+ :sa_data, [:char, 14]
35
+ end
36
+
37
+ class InAddr < FFI::Struct
38
+ layout :s_addr, :in_addr_t
39
+ end
40
+
41
+ class SockaddrIn < FFI::Struct
42
+ layout :sin_len, :uint8,
43
+ :sin_family, :sa_family_t,
44
+ :sin_port, :in_port_t,
45
+ :sin_addr, InAddr,
46
+ :sin_zero, [:char, 8]
47
+ end
48
+
49
+ class U6Addr < FFI::Union
50
+ layout :__u6_addr8, [:uint8, 16],
51
+ :__u6_addr16, [:uint16, 8]
52
+ end
53
+
54
+ class In6Addr < FFI::Struct
55
+ layout :__u6_addr, U6Addr
56
+ end
57
+
58
+ class SockaddrIn6 < FFI::Struct
59
+ layout :sin6_len, :uint8,
60
+ :sin6_family, :sa_family_t,
61
+ :sin6_port, :in_port_t,
62
+ :sin6_flowinfo, :uint32,
63
+ :sin6_addr, In6Addr,
64
+ :sin6_scope_id, :uint32
65
+ end
66
+
67
+
68
+
29
69
  class UvAddrinfo < FFI::Struct
30
70
  layout :flags, :int,
31
71
  :family, :int,
@@ -8,28 +8,15 @@ end
8
8
 
9
9
  module Libuv
10
10
  module Ext
11
- class Sockaddr < FFI::Struct
12
- layout :sa_len, :uint8,
13
- :sa_family, :sa_family_t,
14
- :sa_data, [:char, 15]
15
- end
16
-
17
- class UvAddrinfo < FFI::Struct
18
- layout :flags, :int,
19
- :family, :int,
20
- :socktype, :int,
21
- :protocol, :int,
22
- :addrlen, :socklen_t,
23
- :addr, Sockaddr.by_ref,
24
- :canonname, :string,
25
- :next, :pointer
26
- end
11
+ # Defined in platform code
12
+ class UvAddrinfo < FFI::Struct; end
27
13
 
28
14
  require 'libuv/ext/platform/linux.rb' if FFI::Platform.linux?
29
15
  require 'libuv/ext/platform/unix.rb' if FFI::Platform.unix?
30
16
  require 'libuv/ext/platform/darwin_x64.rb' if FFI::Platform.mac? and FFI::Platform::ARCH == 'x86_64'
31
17
  require 'libuv/ext/platform/windows.rb' if FFI::Platform.windows?
32
18
 
19
+
33
20
  enum :uv_handle_type, [
34
21
  :uv_unknown_handle, 0,
35
22
  :uv_async, # start UV_HANDLE_TYPE_MAP
@@ -108,39 +95,7 @@ module Libuv
108
95
  ]
109
96
 
110
97
  typedef UvBuf.by_ref, :uv_buf_t
111
-
112
- class InAddr < FFI::Struct
113
- layout :s_addr, :in_addr_t
114
- end
115
-
116
- class SockaddrIn < FFI::Struct
117
- layout :sin_len, :uint8,
118
- :sin_family, :sa_family_t,
119
- :sin_port, :in_port_t,
120
- :sin_addr, InAddr,
121
- :sin_zero, [:char, 8]
122
- end
123
-
124
98
  typedef SockaddrIn.by_ref, :sockaddr_in4
125
-
126
- class U6Addr < FFI::Union
127
- layout :__u6_addr8, [:uint8, 16],
128
- :__u6_addr16, [:uint16, 8]
129
- end
130
-
131
- class In6Addr < FFI::Struct
132
- layout :__u6_addr, U6Addr
133
- end
134
-
135
- class SockaddrIn6 < FFI::Struct
136
- layout :sin6_len, :uint8,
137
- :sin6_family, :sa_family_t,
138
- :sin6_port, :in_port_t,
139
- :sin6_flowinfo, :uint32,
140
- :sin6_addr, In6Addr,
141
- :sin6_scope_id, :uint32
142
- end
143
-
144
99
  typedef SockaddrIn6.by_ref, :sockaddr_in6
145
100
 
146
101
 
data/lib/libuv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Libuv
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
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: 1.0.2
4
+ version: 1.0.3
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-08-04 00:00:00.000000000 Z
12
+ date: 2014-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi