nio4r 0.2.0 → 2.7.5

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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libev/Changes +232 -3
  4. data/ext/libev/LICENSE +2 -1
  5. data/ext/libev/README +11 -10
  6. data/ext/libev/ev.c +2249 -473
  7. data/ext/libev/ev.h +165 -135
  8. data/ext/libev/ev_epoll.c +68 -36
  9. data/ext/libev/ev_iouring.c +694 -0
  10. data/ext/libev/ev_kqueue.c +44 -18
  11. data/ext/libev/ev_linuxaio.c +620 -0
  12. data/ext/libev/ev_poll.c +28 -20
  13. data/ext/libev/ev_port.c +23 -10
  14. data/ext/libev/ev_select.c +18 -12
  15. data/ext/libev/ev_vars.h +65 -19
  16. data/ext/libev/ev_win32.c +16 -7
  17. data/ext/libev/ev_wrap.h +236 -160
  18. data/ext/nio4r/.clang-format +16 -0
  19. data/ext/nio4r/bytebuffer.c +465 -0
  20. data/ext/nio4r/extconf.rb +44 -35
  21. data/ext/nio4r/libev.h +3 -4
  22. data/ext/nio4r/monitor.c +186 -54
  23. data/ext/nio4r/nio4r.h +17 -23
  24. data/ext/nio4r/nio4r_ext.c +11 -3
  25. data/ext/nio4r/org/nio4r/ByteBuffer.java +295 -0
  26. data/ext/nio4r/org/nio4r/Monitor.java +176 -0
  27. data/ext/nio4r/org/nio4r/Nio4r.java +104 -0
  28. data/ext/nio4r/org/nio4r/Selector.java +297 -0
  29. data/ext/nio4r/selector.c +350 -182
  30. data/lib/nio/bytebuffer.rb +235 -0
  31. data/lib/nio/monitor.rb +100 -8
  32. data/lib/nio/selector.rb +110 -44
  33. data/lib/nio/version.rb +8 -1
  34. data/lib/nio.rb +47 -16
  35. data/lib/nio4r.rb +7 -0
  36. data/license.md +80 -0
  37. data/readme.md +91 -0
  38. data/releases.md +343 -0
  39. data.tar.gz.sig +2 -0
  40. metadata +114 -79
  41. metadata.gz.sig +0 -0
  42. data/.gitignore +0 -20
  43. data/.rspec +0 -4
  44. data/.travis.yml +0 -7
  45. data/CHANGES.md +0 -10
  46. data/Gemfile +0 -4
  47. data/LICENSE.txt +0 -20
  48. data/README.md +0 -171
  49. data/Rakefile +0 -9
  50. data/examples/echo_server.rb +0 -38
  51. data/ext/libev/README.embed +0 -3
  52. data/ext/libev/test_libev_win32.c +0 -123
  53. data/lib/nio/jruby/monitor.rb +0 -42
  54. data/lib/nio/jruby/selector.rb +0 -135
  55. data/nio4r.gemspec +0 -22
  56. data/spec/nio/monitor_spec.rb +0 -46
  57. data/spec/nio/selector_spec.rb +0 -269
  58. data/spec/spec_helper.rb +0 -3
  59. data/tasks/extension.rake +0 -10
  60. data/tasks/rspec.rake +0 -7
data/ext/libev/ev_poll.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev poll fd activity backend
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2016,2019 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -39,11 +39,14 @@
39
39
 
40
40
  #include <poll.h>
41
41
 
42
- void inline_size
43
- pollidx_init (int *base, int count)
42
+ inline_size
43
+ void
44
+ array_needsize_pollidx (int *base, int offset, int count)
44
45
  {
45
- /* consider using memset (.., -1, ...), which is practically guaranteed
46
- * to work on all systems implementing poll */
46
+ /* using memset (.., -1, ...) is tempting, we we try
47
+ * to be ultraportable
48
+ */
49
+ base += offset;
47
50
  while (count--)
48
51
  *base++ = -1;
49
52
  }
@@ -56,14 +59,14 @@ poll_modify (EV_P_ int fd, int oev, int nev)
56
59
  if (oev == nev)
57
60
  return;
58
61
 
59
- array_needsize (int, pollidxs, pollidxmax, fd + 1, pollidx_init);
62
+ array_needsize (int, pollidxs, pollidxmax, fd + 1, array_needsize_pollidx);
60
63
 
61
64
  idx = pollidxs [fd];
62
65
 
63
66
  if (idx < 0) /* need to allocate a new pollfd */
64
67
  {
65
68
  pollidxs [fd] = idx = pollcnt++;
66
- array_needsize (struct pollfd, polls, pollmax, pollcnt, EMPTY2);
69
+ array_needsize (struct pollfd, polls, pollmax, pollcnt, array_needsize_noinit);
67
70
  polls [idx].fd = fd;
68
71
  }
69
72
 
@@ -77,7 +80,7 @@ poll_modify (EV_P_ int fd, int oev, int nev)
77
80
  {
78
81
  pollidxs [fd] = -1;
79
82
 
80
- if (expect_true (idx < --pollcnt))
83
+ if (ecb_expect_true (idx < --pollcnt))
81
84
  {
82
85
  polls [idx] = polls [pollcnt];
83
86
  pollidxs [polls [idx].fd] = idx;
@@ -90,12 +93,12 @@ poll_poll (EV_P_ ev_tstamp timeout)
90
93
  {
91
94
  struct pollfd *p;
92
95
  int res;
93
-
96
+
94
97
  EV_RELEASE_CB;
95
- res = poll (polls, pollcnt, ev_timeout_to_ms (timeout));
98
+ res = poll (polls, pollcnt, EV_TS_TO_MSEC (timeout));
96
99
  EV_ACQUIRE_CB;
97
100
 
98
- if (expect_false (res < 0))
101
+ if (ecb_expect_false (res < 0))
99
102
  {
100
103
  if (errno == EBADF)
101
104
  fd_ebadf (EV_A);
@@ -107,14 +110,17 @@ poll_poll (EV_P_ ev_tstamp timeout)
107
110
  else
108
111
  for (p = polls; res; ++p)
109
112
  {
110
- assert (("libev: poll() returned illegal result, broken BSD kernel?", p < polls + pollcnt));
113
+ assert (("libev: poll returned illegal result, broken BSD kernel?", p < polls + pollcnt));
111
114
 
112
- if (expect_false (p->revents)) /* this expect is debatable */
115
+ if (ecb_expect_false (p->revents)) /* this expect is debatable */
113
116
  {
114
117
  --res;
115
118
 
116
- if (expect_false (p->revents & POLLNVAL))
117
- fd_kill (EV_A_ p->fd);
119
+ if (ecb_expect_false (p->revents & POLLNVAL))
120
+ {
121
+ assert (("libev: poll found invalid fd in poll set", 0));
122
+ fd_kill (EV_A_ p->fd);
123
+ }
118
124
  else
119
125
  fd_event (
120
126
  EV_A_
@@ -126,12 +132,13 @@ poll_poll (EV_P_ ev_tstamp timeout)
126
132
  }
127
133
  }
128
134
 
129
- int inline_size
135
+ inline_size
136
+ int
130
137
  poll_init (EV_P_ int flags)
131
138
  {
132
- backend_fudge = 0.; /* posix says this is zero */
133
- backend_modify = poll_modify;
134
- backend_poll = poll_poll;
139
+ backend_mintime = EV_TS_CONST (1e-3);
140
+ backend_modify = poll_modify;
141
+ backend_poll = poll_poll;
135
142
 
136
143
  pollidxs = 0; pollidxmax = 0;
137
144
  polls = 0; pollmax = 0; pollcnt = 0;
@@ -139,7 +146,8 @@ poll_init (EV_P_ int flags)
139
146
  return EVBACKEND_POLL;
140
147
  }
141
148
 
142
- void inline_size
149
+ inline_size
150
+ void
143
151
  poll_destroy (EV_P)
144
152
  {
145
153
  ev_free (pollidxs);
data/ext/libev/ev_port.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev solaris event port backend
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2019 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -55,7 +55,8 @@
55
55
  #include <string.h>
56
56
  #include <errno.h>
57
57
 
58
- void inline_speed
58
+ inline_speed
59
+ void
59
60
  port_associate_and_check (EV_P_ int fd, int ev)
60
61
  {
61
62
  if (0 >
@@ -68,7 +69,10 @@ port_associate_and_check (EV_P_ int fd, int ev)
68
69
  )
69
70
  {
70
71
  if (errno == EBADFD)
71
- fd_kill (EV_A_ fd);
72
+ {
73
+ assert (("libev: port_associate found invalid fd", errno != EBADFD));
74
+ fd_kill (EV_A_ fd);
75
+ }
72
76
  else
73
77
  ev_syserr ("(libev) port_associate");
74
78
  }
@@ -128,7 +132,7 @@ port_poll (EV_P_ ev_tstamp timeout)
128
132
  }
129
133
  }
130
134
 
131
- if (expect_false (nget == port_eventmax))
135
+ if (ecb_expect_false (nget == port_eventmax))
132
136
  {
133
137
  ev_free (port_events);
134
138
  port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1);
@@ -136,7 +140,8 @@ port_poll (EV_P_ ev_tstamp timeout)
136
140
  }
137
141
  }
138
142
 
139
- int inline_size
143
+ inline_size
144
+ int
140
145
  port_init (EV_P_ int flags)
141
146
  {
142
147
  /* Initialize the kernel queue */
@@ -147,9 +152,15 @@ port_init (EV_P_ int flags)
147
152
 
148
153
  fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
149
154
 
150
- backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */
151
- backend_modify = port_modify;
152
- backend_poll = port_poll;
155
+ /* if my reading of the opensolaris kernel sources are correct, then
156
+ * opensolaris does something very stupid: it checks if the time has already
157
+ * elapsed and doesn't round up if that is the case, otherwise it DOES round
158
+ * up. Since we can't know what the case is, we need to guess by using a
159
+ * "large enough" timeout. Normally, 1e-9 would be correct.
160
+ */
161
+ backend_mintime = EV_TS_CONST (1e-3); /* needed to compensate for port_getn returning early */
162
+ backend_modify = port_modify;
163
+ backend_poll = port_poll;
153
164
 
154
165
  port_eventmax = 64; /* initial number of events receivable per poll */
155
166
  port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
@@ -157,13 +168,15 @@ port_init (EV_P_ int flags)
157
168
  return EVBACKEND_PORT;
158
169
  }
159
170
 
160
- void inline_size
171
+ inline_size
172
+ void
161
173
  port_destroy (EV_P)
162
174
  {
163
175
  ev_free (port_events);
164
176
  }
165
177
 
166
- void inline_size
178
+ inline_size
179
+ void
167
180
  port_fork (EV_P)
168
181
  {
169
182
  close (backend_fd);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev select fd activity backend
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -108,7 +108,7 @@ select_modify (EV_P_ int fd, int oev, int nev)
108
108
  int word = fd / NFDBITS;
109
109
  fd_mask mask = 1UL << (fd % NFDBITS);
110
110
 
111
- if (expect_false (vec_max <= word))
111
+ if (ecb_expect_false (vec_max <= word))
112
112
  {
113
113
  int new_max = word + 1;
114
114
 
@@ -171,7 +171,7 @@ select_poll (EV_P_ ev_tstamp timeout)
171
171
  #endif
172
172
  EV_ACQUIRE_CB;
173
173
 
174
- if (expect_false (res < 0))
174
+ if (ecb_expect_false (res < 0))
175
175
  {
176
176
  #if EV_SELECT_IS_WINSOCKET
177
177
  errno = WSAGetLastError ();
@@ -195,7 +195,12 @@ select_poll (EV_P_ ev_tstamp timeout)
195
195
  */
196
196
  if (errno == EINVAL)
197
197
  {
198
- ev_sleep (timeout);
198
+ if (timeout)
199
+ {
200
+ unsigned long ms = EV_TS_TO_MSEC (timeout);
201
+ Sleep (ms ? ms : 1);
202
+ }
203
+
199
204
  return;
200
205
  }
201
206
  #endif
@@ -231,7 +236,7 @@ select_poll (EV_P_ ev_tstamp timeout)
231
236
  if (FD_ISSET (handle, (fd_set *)vec_eo)) events |= EV_WRITE;
232
237
  #endif
233
238
 
234
- if (expect_true (events))
239
+ if (ecb_expect_true (events))
235
240
  fd_event (EV_A_ fd, events);
236
241
  }
237
242
  }
@@ -257,7 +262,7 @@ select_poll (EV_P_ ev_tstamp timeout)
257
262
  events |= word_r & mask ? EV_READ : 0;
258
263
  events |= word_w & mask ? EV_WRITE : 0;
259
264
 
260
- if (expect_true (events))
265
+ if (ecb_expect_true (events))
261
266
  fd_event (EV_A_ word * NFDBITS + bit, events);
262
267
  }
263
268
  }
@@ -266,12 +271,13 @@ select_poll (EV_P_ ev_tstamp timeout)
266
271
  #endif
267
272
  }
268
273
 
269
- int inline_size
274
+ inline_size
275
+ int
270
276
  select_init (EV_P_ int flags)
271
277
  {
272
- backend_fudge = 0.; /* posix says this is zero */
273
- backend_modify = select_modify;
274
- backend_poll = select_poll;
278
+ backend_mintime = EV_TS_CONST (1e-6);
279
+ backend_modify = select_modify;
280
+ backend_poll = select_poll;
275
281
 
276
282
  #if EV_SELECT_USE_FD_SET
277
283
  vec_ri = ev_malloc (sizeof (fd_set)); FD_ZERO ((fd_set *)vec_ri);
@@ -295,7 +301,8 @@ select_init (EV_P_ int flags)
295
301
  return EVBACKEND_SELECT;
296
302
  }
297
303
 
298
- void inline_size
304
+ inline_size
305
+ void
299
306
  select_destroy (EV_P)
300
307
  {
301
308
  ev_free (vec_ri);
@@ -307,4 +314,3 @@ select_destroy (EV_P)
307
314
  #endif
308
315
  }
309
316
 
310
-
data/ext/libev/ev_vars.h CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * loop member variable declarations
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2019 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -43,6 +43,17 @@ VARx(ev_tstamp, now_floor) /* last time we refreshed rt_time */
43
43
  VARx(ev_tstamp, mn_now) /* monotonic clock "now" */
44
44
  VARx(ev_tstamp, rtmn_diff) /* difference realtime - monotonic time */
45
45
 
46
+ /* for reverse feeding of events */
47
+ VARx(W *, rfeeds)
48
+ VARx(int, rfeedmax)
49
+ VARx(int, rfeedcnt)
50
+
51
+ VAR (pendings, ANPENDING *pendings [NUMPRI])
52
+ VAR (pendingmax, int pendingmax [NUMPRI])
53
+ VAR (pendingcnt, int pendingcnt [NUMPRI])
54
+ VARx(int, pendingpri) /* highest priority currently pending */
55
+ VARx(ev_prepare, pending_w) /* dummy pending watcher */
56
+
46
57
  VARx(ev_tstamp, io_blocktime)
47
58
  VARx(ev_tstamp, timeout_blocktime)
48
59
 
@@ -51,28 +62,17 @@ VARx(int, activecnt) /* total number of active events ("refcount") */
51
62
  VARx(EV_ATOMIC_T, loop_done) /* signal by ev_break */
52
63
 
53
64
  VARx(int, backend_fd)
54
- VARx(ev_tstamp, backend_fudge) /* assumed typical timer resolution */
65
+ VARx(ev_tstamp, backend_mintime) /* assumed typical timer resolution */
55
66
  VAR (backend_modify, void (*backend_modify)(EV_P_ int fd, int oev, int nev))
56
67
  VAR (backend_poll , void (*backend_poll)(EV_P_ ev_tstamp timeout))
57
68
 
58
69
  VARx(ANFD *, anfds)
59
70
  VARx(int, anfdmax)
60
71
 
61
- VAR (pendings, ANPENDING *pendings [NUMPRI])
62
- VAR (pendingmax, int pendingmax [NUMPRI])
63
- VAR (pendingcnt, int pendingcnt [NUMPRI])
64
- VARx(ev_prepare, pending_w) /* dummy pending watcher */
65
-
66
- /* for reverse feeding of events */
67
- VARx(W *, rfeeds)
68
- VARx(int, rfeedmax)
69
- VARx(int, rfeedcnt)
70
-
71
- #if EV_USE_EVENTFD || EV_GENWRAP
72
- VARx(int, evfd)
73
- #endif
74
72
  VAR (evpipe, int evpipe [2])
75
73
  VARx(ev_io, pipe_w)
74
+ VARx(EV_ATOMIC_T, pipe_write_wanted)
75
+ VARx(EV_ATOMIC_T, pipe_write_skipped)
76
76
 
77
77
  #if !defined(_WIN32) || EV_GENWRAP
78
78
  VARx(pid_t, curpid)
@@ -107,7 +107,48 @@ VARx(int, epoll_epermcnt)
107
107
  VARx(int, epoll_epermmax)
108
108
  #endif
109
109
 
110
+ #if EV_USE_LINUXAIO || EV_GENWRAP
111
+ VARx(aio_context_t, linuxaio_ctx)
112
+ VARx(int, linuxaio_iteration)
113
+ VARx(struct aniocb **, linuxaio_iocbps)
114
+ VARx(int, linuxaio_iocbpmax)
115
+ VARx(struct iocb **, linuxaio_submits)
116
+ VARx(int, linuxaio_submitcnt)
117
+ VARx(int, linuxaio_submitmax)
118
+ VARx(ev_io, linuxaio_epoll_w)
119
+ #endif
120
+
121
+ #if EV_USE_IOURING || EV_GENWRAP
122
+ VARx(int, iouring_fd)
123
+ VARx(unsigned, iouring_to_submit);
124
+ VARx(int, iouring_entries)
125
+ VARx(int, iouring_max_entries)
126
+ VARx(void *, iouring_sq_ring)
127
+ VARx(void *, iouring_cq_ring)
128
+ VARx(void *, iouring_sqes)
129
+ VARx(uint32_t, iouring_sq_ring_size)
130
+ VARx(uint32_t, iouring_cq_ring_size)
131
+ VARx(uint32_t, iouring_sqes_size)
132
+ VARx(uint32_t, iouring_sq_head)
133
+ VARx(uint32_t, iouring_sq_tail)
134
+ VARx(uint32_t, iouring_sq_ring_mask)
135
+ VARx(uint32_t, iouring_sq_ring_entries)
136
+ VARx(uint32_t, iouring_sq_flags)
137
+ VARx(uint32_t, iouring_sq_dropped)
138
+ VARx(uint32_t, iouring_sq_array)
139
+ VARx(uint32_t, iouring_cq_head)
140
+ VARx(uint32_t, iouring_cq_tail)
141
+ VARx(uint32_t, iouring_cq_ring_mask)
142
+ VARx(uint32_t, iouring_cq_ring_entries)
143
+ VARx(uint32_t, iouring_cq_overflow)
144
+ VARx(uint32_t, iouring_cq_cqes)
145
+ VARx(ev_tstamp, iouring_tfd_to)
146
+ VARx(int, iouring_tfd)
147
+ VARx(ev_io, iouring_tfd_w)
148
+ #endif
149
+
110
150
  #if EV_USE_KQUEUE || EV_GENWRAP
151
+ VARx(pid_t, kqueue_fd_pid)
111
152
  VARx(struct kevent *, kqueue_changes)
112
153
  VARx(int, kqueue_changemax)
113
154
  VARx(int, kqueue_changecnt)
@@ -180,13 +221,17 @@ VAR (fs_hash, ANFS fs_hash [EV_INOTIFY_HASHSIZE])
180
221
  #endif
181
222
 
182
223
  VARx(EV_ATOMIC_T, sig_pending)
183
- VARx(int, nosigmask)
184
224
  #if EV_USE_SIGNALFD || EV_GENWRAP
185
225
  VARx(int, sigfd)
186
226
  VARx(ev_io, sigfd_w)
187
227
  VARx(sigset_t, sigfd_set)
188
228
  #endif
189
229
 
230
+ #if EV_USE_TIMERFD || EV_GENWRAP
231
+ VARx(int, timerfd) /* timerfd for time jump detection */
232
+ VARx(ev_io, timerfd_w)
233
+ #endif
234
+
190
235
  VARx(unsigned int, origflags) /* original loop flags */
191
236
 
192
237
  #if EV_FEATURE_API || EV_GENWRAP
@@ -194,9 +239,10 @@ VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
194
239
  VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */
195
240
 
196
241
  VARx(void *, userdata)
197
- VAR (release_cb, void (*release_cb)(EV_P))
198
- VAR (acquire_cb, void (*acquire_cb)(EV_P))
199
- VAR (invoke_cb , void (*invoke_cb) (EV_P))
242
+ /* C++ doesn't support the ev_loop_callback typedef here. stinks. */
243
+ VAR (release_cb, void (*release_cb)(EV_P) EV_NOEXCEPT)
244
+ VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_NOEXCEPT)
245
+ VAR (invoke_cb , ev_loop_callback invoke_cb)
200
246
  #endif
201
247
 
202
248
  #undef VARx
data/ext/libev/ev_win32.c CHANGED
@@ -39,15 +39,22 @@
39
39
 
40
40
  #ifdef _WIN32
41
41
 
42
- /* timeb.h is actually xsi legacy functionality */
43
- #include <sys/timeb.h>
44
-
45
42
  /* note: the comment below could not be substantiated, but what would I care */
46
43
  /* MSDN says this is required to handle SIGFPE */
47
44
  /* my wild guess would be that using something floating-pointy is required */
48
45
  /* for the crt to do something about it */
49
46
  volatile double SIGFPE_REQ = 0.0f;
50
47
 
48
+ static SOCKET
49
+ ev_tcp_socket (void)
50
+ {
51
+ #if EV_USE_WSASOCKET
52
+ return WSASocket (AF_INET, SOCK_STREAM, 0, 0, 0, 0);
53
+ #else
54
+ return socket (AF_INET, SOCK_STREAM, 0);
55
+ #endif
56
+ }
57
+
51
58
  /* oh, the humanity! */
52
59
  static int
53
60
  ev_pipe (int filedes [2])
@@ -59,7 +66,7 @@ ev_pipe (int filedes [2])
59
66
  SOCKET listener;
60
67
  SOCKET sock [2] = { -1, -1 };
61
68
 
62
- if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
69
+ if ((listener = ev_tcp_socket ()) == INVALID_SOCKET)
63
70
  return -1;
64
71
 
65
72
  addr.sin_family = AF_INET;
@@ -75,12 +82,14 @@ ev_pipe (int filedes [2])
75
82
  if (listen (listener, 1))
76
83
  goto fail;
77
84
 
78
- if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
85
+ if ((sock [0] = ev_tcp_socket ()) == INVALID_SOCKET)
79
86
  goto fail;
80
87
 
81
88
  if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
82
89
  goto fail;
83
90
 
91
+ /* TODO: returns INVALID_SOCKET on winsock accept, not < 0. fix it */
92
+ /* when convenient, probably by just removing error checking altogether? */
84
93
  if ((sock [1] = accept (listener, 0, 0)) < 0)
85
94
  goto fail;
86
95
 
@@ -145,8 +154,8 @@ ev_time (void)
145
154
  ui.u.LowPart = ft.dwLowDateTime;
146
155
  ui.u.HighPart = ft.dwHighDateTime;
147
156
 
148
- /* msvc cannot convert ulonglong to double... yes, it is that sucky */
149
- return (LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-7;
157
+ /* also, msvc cannot convert ulonglong to double... yes, it is that sucky */
158
+ return EV_TS_FROM_USEC (((LONGLONG)(ui.QuadPart - 116444736000000000) * 1e-1));
150
159
  }
151
160
 
152
161
  #endif