Ben Noordhuis
c8c9fe1c74
unix: move memset out of recvmsg inner loop
2012-06-05 15:42:20 +02:00
Ben Noordhuis
738b31eb3a
unix: fix loop starvation under high network load
...
uv__read() and uv__udp_recvmsg() read incoming data in a loop. If data comes
in at high speeds, the kernel receive buffer never drains and said functions
never terminate, stalling the event loop indefinitely. Limit the number of
consecutive reads to 32 to stop that from happening.
The number 32 was chosen at random. Empirically, it seems to maintain a high
throughput while still making the event loop move forward at a reasonable pace.
2012-06-05 15:27:51 +02:00
Ben Noordhuis
890d443558
unix: shave about 100 bytes off uv_udp_send_t
2012-05-23 23:21:08 +02:00
Ben Noordhuis
2609e43632
unix: remove unnecessary functions in udp.c
2012-05-23 21:18:40 +02:00
Ben Noordhuis
2b09cc2246
unix: fix up asserts in udp.c
2012-05-23 21:08:40 +02:00
Ben Noordhuis
3bc9707054
unix: replace ev_io with uv__io_t
...
Replace ev_io usage with wrapper constructs.
This is preliminary work for the transition to a libev-less linux backend.
2012-05-23 03:42:32 +02:00
Ben Noordhuis
9efa8b3571
unix, windows: rework reference counting scheme
...
This commit changes how the event loop determines if it needs to stay alive.
Previously, an internal counter was increased whenever a handle got created
and decreased again when the handle was closed.
While conceptually simple, it turned out hard to work with: you often want
to keep the event loop alive only if the handle is actually doing something.
Stopped or inactive handles were a frequent source of hanging event loops.
That's why this commit changes the reference counting scheme to a model where
a handle only references the event loop when it's active. 'Active' means
different things for different handle types, e.g.:
* timers: ticking
* sockets: reading, writing or listening
* processes: always active (for now, subject to change)
* idle, check, prepare: only active when started
This commit also changes how the uv_ref() and uv_unref() functions work: they
now operate on the level of individual handles, not the whole event loop.
The Windows implementation was done by Bert Belder.
2012-05-17 07:07:53 +02:00
Ben Noordhuis
ab3b307df3
unix: clean up uv__req_init()
2012-04-18 22:30:20 +02:00
Ben Noordhuis
42d3533487
unix: fix udp_options test on OS X and Solaris
...
setsockopt(IP_TTL) will happily let you set a TTL > 255 on OS X, cap it.
-1 or 0 is a valid TTL on Linux but not portable, deny it.
2012-04-11 14:51:46 +00:00
Ben Noordhuis
5a8446c309
unix: move handle specific close logic out of core.c
2012-04-04 05:30:15 -07:00
Ben Noordhuis
4ff0898c5f
unix: replace uv__close() with close()
...
uv__close() was deprecated a while ago. It's been an alias for close() ever
since. Remove it.
2012-03-21 02:11:18 +01:00
isaacs
243cfcd078
Merge remote-tracking branch 'ry/v0.6'
2012-01-31 18:00:59 -08:00
Ben Noordhuis
45d7bd88c9
unix: explain SO_REUSEADDR and SO_REUSEPORT
2012-01-31 16:52:27 +01:00
Ben Noordhuis
332b72e589
sunos: fix uv_udp_set_ttl and uv_udp_set_multicast_loop
...
It turns out that setsockopt(IP_TTL) *does* expect an int, whereas
setsockopt(IP_MULTICAST_LOOP) needs a char.
2012-01-28 01:19:49 +01:00
Ben Noordhuis
16124bb34e
sunos: fix uv_udp_set_ttl and uv_udp_multicast_ttl
...
The argument to setsockopt(IP_TTL|IP_MULTICAST_TTL) should be a char, not an int
like on other Unices.
2012-01-28 00:11:47 +01:00
Ben Noordhuis
3de0411591
Merge remote-tracking branch 'origin/v0.6'
2012-01-27 22:23:26 +01:00
Ben Noordhuis
9c76d0d742
unix: turn on SO_REUSEPORT for UDP sockets
...
Required on BSD-like systems for local UDP multicast. Without it, the bind()
call fails with EADDRINUSE.
2012-01-27 00:49:57 +01:00
Ben Noordhuis
b88bc43543
unix: implement uv_udp_set_multicast_loop()
2012-01-24 00:07:22 +01:00
Ben Noordhuis
e710fdb518
unix: implement uv_udp_set_ttl()
2012-01-24 00:07:22 +01:00
Dan VerWeire
497b1ecd00
unix: add uv_udp_set_broadcast() and uv_udp_set_multicast_ttl()
2012-01-21 03:06:47 +01:00
Dan VerWeire
b674187c38
unix: set SO_REUSEADDR before binding
2012-01-21 03:06:43 +01:00
Ben Noordhuis
0e6e4abedc
unix: fix udp recv_start refcount
...
Calling uv_udp_recv_start() should not bump the event loop's reference count.
Fixes failing test udp_ref2.
2012-01-14 01:44:27 +01:00
Ben Noordhuis
52fba1a38f
unix: fix compiler warning
2012-01-12 16:00:31 +01:00
Shigeki Ohtsu
ba52023ef3
Fix missing increments of loop->counters
2011-12-12 18:01:26 +01:00
Roman Shtylman
a3d1f6fd6f
add uv_udp_set_membership for unix multicast support
...
- test-udp-multicast-join tests that multicast packets can be received
- stub src/win/udp.c until support added
2011-10-11 21:25:20 +02:00
Erick Tryzelaar
4c329060ca
unix,win: Start unifying shared bind code.
2011-10-04 16:46:39 -07:00
Erick Tryzelaar
23796d208c
Fixes #76 . Unify OS error reporting
...
As a nice fringe benefit, this also shaves a word
off of a windows TCP handle by replacing "uv_err_t
bind_error" with "int bind_error".
2011-09-27 19:05:33 -07:00
Erick Tryzelaar
1d7e61fafa
unix,win: Check bind receives right socket type
2011-09-27 19:05:33 -07:00
Ben Noordhuis
c89a75f5a2
unix: fix compiler warning in kqueue.c, tcp.c, udp.c
...
Include <unistd.h>, it contains the definition of close().
2011-09-28 00:57:20 +02:00
Ben Noordhuis
1cca230d76
Merge remote-tracking branch 'origin/v0.6'
2012-01-23 13:27:47 +01:00
Ben Noordhuis
454e0212b0
unix: clean up udp read/write watchers
2012-01-18 20:19:59 +01:00
Ben Noordhuis
28b0867f03
unix: clean up udp shutdown sequence
2012-01-18 20:18:57 +01:00
Ben Noordhuis
01441ab02f
unix: fix close() of potentially uninitialized fd
2011-09-25 02:49:21 +02:00
Bert Belder
360f4119e4
Make getsockname/getpeername handle uninitialized sockets better
2011-09-04 19:18:56 +02:00
Bert Belder
12b01e95f9
Specialize uv_xxx_getsockname, add uv_tcp_getpeername
2011-09-04 04:49:13 +02:00
Ryan Dahl
58461d5ae7
split out unix's udp source
2011-08-31 11:23:29 -07:00