Commit Graph

517 Commits

Author SHA1 Message Date
Eric Holk
6abddca18b Rewriting shared_arc to work around Issue #2444.
Sadly, this exposes another ICE when trying to use the new version with Graph500
2012-05-30 12:03:51 -07:00
Eric Holk
5e35d49a50 Moving the arc tests into arc.rs. 2012-05-29 11:30:10 -07:00
Eric Holk
aa2efc05ea Adding shared_arc to hide some of the tedium of sharing an arc between tasks.
Also added some asserts and logging to trans.

Modified graph500 to use the shared_arc, but this unfortunately doesn't work due to #2444.
2012-05-29 10:43:19 -07:00
Erick Tryzelaar
ed5af70a36 std: add json::to_str and json::to_json iface. 2012-05-28 12:14:41 -07:00
Benjamin Kircher
360194d282 std: Fix bitv each() method (issue 2363) 2012-05-27 22:08:48 +02:00
Brian Anderson
432c6cbde9 core: Make range follow the for loop protocol 2012-05-26 02:28:00 -07:00
Michael Sullivan
8668d06400 Get rid of many implicit copies as a preliminary to Issue #2448. 2012-05-25 16:39:35 -07:00
Brian Anderson
d89b4c8c61 std: Modify arc to tolerate upcoming change to uniques 2012-05-25 16:22:29 -07:00
Brian Anderson
7c2e981381 std: Don't export get_monitor_task_gl 2012-05-25 11:03:32 -07:00
Brian Anderson
78b664fead std: More iotask cleanup 2012-05-25 11:03:31 -07:00
Brian Anderson
937ef188e3 std: Remove unused iotask field active 2012-05-25 11:03:31 -07:00
Brian Anderson
81b8e20f31 std: Rename uv::hl to uv::iotask. Additional cleanup 2012-05-25 11:03:29 -07:00
Brian Anderson
59262dfc62 std: Move spawn_high_level_loop to uv::hl 2012-05-24 22:52:51 -07:00
Brian Anderson
d4db1beabf std: Separate weakening the I/O task from spawning it 2012-05-24 22:26:30 -07:00
Brian Anderson
95898b4cfc std: Simplify run_high_level_loop further 2012-05-24 22:05:31 -07:00
Brian Anderson
623acaa013 std: Remove unused args from run_high_level_loop 2012-05-24 21:50:35 -07:00
Brian Anderson
444ff687a2 std: Move loop creation into run_high_level_loop 2012-05-24 21:50:35 -07:00
Brian Anderson
2a82a9907f std: Clean up uv_global_loop 2012-05-24 21:50:33 -07:00
Brian Anderson
26ed1e91c8 std: Rename spawn_libuv_weak_task to spawn_high_level_loop 2012-05-24 21:03:30 -07:00
Brian Anderson
06ff3f8b4b std: Use more concise code in uv::hl 2012-05-24 20:31:27 -07:00
Brian Anderson
77bbd72171 std: Remove unused variables 2012-05-24 20:31:27 -07:00
Brian Anderson
a8c8c8ae28 std: FIXME's and cleanups for uv 2012-05-24 16:42:16 -07:00
Eric Holk
30f8555544 Some comments giving some idea how to use these things. 2012-05-24 15:05:39 -07:00
Niko Matsakis
ccd8d5573e remove dead assignments 2012-05-24 13:35:57 -07:00
Niko Matsakis
6ca6a3b80b rewrite arc to use region & expressions (also making it pass borrowck) 2012-05-24 05:19:44 -07:00
Niko Matsakis
58988c3565 changes to get std passing borrowck 2012-05-23 17:25:56 -07:00
Eric Holk
6fa1a084f7 A shareable atomically reference counted pointer wrapper.
Needs more tests to ensure safety, and probably some more work on usability too.
2012-05-23 14:58:16 -07:00
Brian Anderson
8ec467d521 std: Update timer for new kind rules 2012-05-22 22:29:17 -07:00
Jeff Olson
92e9e736fa std: high-level libuv-leverage APIs now take a hl_loop as arg (tcp/timer) 2012-05-22 22:29:17 -07:00
Jeff Olson
b0b175214a std: more work on uv tests to endure valgrind's machinations against them
- change port of tcp server test in uv_ll to avoid conflict w/ test in
net::tcp
- a few places the tcp::read fn is used in test w/ a timeout.. suspend
use of the timeout from here on out.
2012-05-22 22:29:17 -07:00
Jeff Olson
c7656f67ad std:: adding tcp::read fn as simple, blocking read operation, akin to write
also: read_future ala write_future .. woooooohooooooooo
2012-05-22 22:29:17 -07:00
Jeff Olson
c2ae062e90 std: adding tcp::write_future for non-block tcp writes, docs cleanup 2012-05-22 22:29:17 -07:00
Jeff Olson
9b10359041 std: several minor cleanups wrt codereview.. see extended comments
* there are a few places where I was experimenting w/ using `alt` in places
where `if`/`else` would've sufficed. don't drink the koolaid!
* I had an unneeded `else` structure (the `if` branch that preceeded
concluded with a `fail` statement.. I added the `fail` later in the dev
cycle for this branch, so I forgot to remove the `else` after doing so)
* consistent wrt `prop_name: value` vs. `prop_name : value` in record decl
and initialization
* change an `alt` exp on an `ip_addr` to actually be exhaustive,
instead of using a catch-all clause
2012-05-22 22:29:17 -07:00
Jeff Olson
7de1a68217 std: add try_parse_addr and change an alt w/ ip_addr::ipv6 to avoid warning 2012-05-22 22:29:17 -07:00
Jeff Olson
a40f550ed5 std: more docs and some methods for types in net::tcp 2012-05-22 22:29:17 -07:00
Jeff Olson
a4b1e965e2 std: ignoring timer test that seems to be race-failing b/c valgrind
.. this test fails frequently, locally, when ran with the batch of other
global_loop tests running due to how valgrind deals with multithreading
in the test app. not sure what to do, here.
2012-05-22 22:29:17 -07:00
Jeff Olson
6c6a47bf22 std: splitting out tcp server API + tests
- we now have two interfaces for the TCP/IP server/listener workflow,
based on different user approaches surrounding how to deal with the
flow of accept a new tcp connection:

1. the "original" API closely mimics the low-level libuv API, in that we
have an on_connect_cb that the user provides *that is ran on the libuv
thread*. In this callback, the user can accept() a connection, turning it
into a tcp_socket.. of course, before accepting, they have the option
of passing it to a new task, provided they *make the cb block until
the accept is done* .. this is because, in libuv, you have to do the
uv_accept call in the span of that on_connect_cb callback that gets fired
when a new connection comes in. thems the breaks..

I wanted to just get rid of this API, because the general proposition of
users always running code on the libuv thread sounds like an invitation
for many future headaches. the API restriction to have to choose to
immediately accept a connection (and allow the user to block libuv as
needed) isn't too bad for power users who could conceive of circumstances
where they would drop an incoming TCP connection and know what they're
doing, in general.

but as a general API, I thought this was a bit cumbersome, so I ended up
devising..

2. an API that is initiated with a call to `net::tcp::new_listener()` ..
has a similar signature to `net::tcp::listen()`, except that is just
returns an object that sort of behaves like a `comm::port`. Users can
block on the `tcp_conn_port` to receive new connections, either in the
current task or in a new task, depending on which API route they take
(`net::tcp::conn_recv` or `net::tcp::conn_recv_spawn` respectively).. there
is also a `net::tcp::conn_peek` function that will do a peek on the
underlying port to see if there are pending connections.

The main difference, with this API, is that the low-level libuv glue is
going to *accept every connection attempt*, along with the overhead that
that brings. But, this is a much more hassle-free API for 95% of use
cases and will probably be the one that most users will want to reach for.
2012-05-22 22:29:17 -07:00
Jeff Olson
e9c6416df6 std: splitting out tcp server API WIP 2012-05-22 22:29:17 -07:00
Jeff Olson
d02b3dffa4 std: reworking how some net and libuv modules are exported in the rc
.. turns out that, without the export, the modules aren't accessible
outside of the crate, itself. I thought that, by importing some module
into another (nesting it) and exporting from that nested module (which
is, itself, exported from std.rc) that my mod would be in the build
artifact. This doesn't appear to be the case. learning is fun!
2012-05-22 22:29:17 -07:00
Jeff Olson
733881d852 std: tightening up net::tcp, server/client test done, still has races..
.. going to rework the listen() API to be non-blocking.
2012-05-22 22:29:16 -07:00
Jeff Olson
a4127d3fc6 std: change sig of uv::ll::accept, again. 2012-05-22 22:29:16 -07:00
Jeff Olson
465412aeff std: first-pass at a tcp server API, with a basic (non-robust) test
also whitespace cleanup

.. for now, the test just spins up the server and listens for messages,
echoing them back to an output port. there's a "kill" msg that it will
listen for. need to point the tcp client and server test impls at each
other for a loopback server/client test, like how its done in uv::ll

once ipv6 parse/format lands, i can add another test using the entirely
same codebase, but substituting an ip_addr ipv6 varient for the ipv4
varient used in the existing code

still need some other plumbing to get the client/server tests to work
together.
2012-05-22 22:29:16 -07:00
Jeff Olson
f2fd3bcf17 std: FIXME stub net::ip::ip_addr::ipv6 variant...needs parse/format impl
still need implementation for parsing/output formatting and (perhaps?)
representation (for now, i just followef the ipv4 variant's lead and
am representing it as a tuple of 8x u16).

parsing an ipv6 addr is way more complex than parsing an ipv4 addr, so
i'm putting off an implementation here, for now.

candidate solutions:
- could use getaddrinfo() (exists on both POSIX and windows), but with
incompatible fn signatures.
- libuv has a way to parse an ipv6 string into
a sockaddr_in6, but it also requires a port, so it's probably not aprop
for ip_addr
2012-05-22 22:29:16 -07:00
Jeff Olson
64048d43d6 std: makeing uv::ll::listen/accept use generic params for ptr args
more flexibility..
2012-05-22 22:29:16 -07:00
Jeff Olson
83cca50240 std: change tcp_*_result to use result::result.. flatter! 2012-05-22 22:29:16 -07:00
Jeff Olson
3d8f7d644b std: no longer return uv::ll::err_data records from net::tcp
they're changed into a net::tcp::tcp_err_data record, for now. once the
scope of possible tcp errors, from libuv, is established ill create an
err type for each one and return those where they might occur
2012-05-22 22:29:16 -07:00
Jeff Olson
565c5d694a std: impl for high-level tcp client/request workflow 2012-05-22 22:29:16 -07:00
Jeff Olson
7e114b200a std: impl of net::tcp::write and make net::tcp::tcp_socket a resource 2012-05-22 22:29:16 -07:00
Jeff Olson
5590dfc857 std: tweak uv::ll::write signature and make it generic/more flexible 2012-05-22 22:29:16 -07:00
Jeff Olson
550b34b782 std: impl for net::tcp::connect 2012-05-22 22:29:15 -07:00
Jeff Olson
bc846ce7e3 std: export net::ip::format_addr 2012-05-22 22:29:15 -07:00
Jeff Olson
08b3048c43 std: misc cleanup for uv::ll
* tweaked the layout of sockaddr_in6 struct in anticipation of future use
* changed several uv:ll fn signatures to use generics and be more flexible
with ptr types they get passed
* add uv_err_data and a help fn to return it.. packages up err_name and
err_msg info from uv_get_last_error() stuff..
2012-05-22 22:29:15 -07:00
Jeff Olson
d99b7bcb2f std: pushing existing code in net.rs -> net_ip.rs and re-import/exporting 2012-05-22 22:29:15 -07:00
Jeff Olson
ffdaf14dd9 initial stab at API for std::net::tcp 2012-05-22 22:29:15 -07:00
Eric Holk
24431520bf Removing par.rs, since it's not usable now anyway. 2012-05-22 15:31:39 -07:00
Eric Holk
a785f3fc95 Adding a module with parallel vector operations.
This should go in libstd, but currently resolve bugs make this not
work.
2012-05-22 15:31:38 -07:00
Eric Holk
0b2f2cabbe Send is no longer a subkind of copy. This allows for sendable, but non-copyable resources. Closes #2420. 2012-05-22 14:10:32 -07:00
Niko Matsakis
83ee4ac5ea impl-ify map 2012-05-22 10:02:34 -07:00
Brian Anderson
b4da0364f9 Merge pull request #2413 from erickt/master
a couple misc changes
2012-05-21 17:32:12 -07:00
Brian Anderson
6d8cffa991 std: Make timer tests more reliable under valgrind 2012-05-21 17:29:00 -07:00
Niko Matsakis
34b42eeb65 change list so that it must be used in a purely boxed fashion
The old way was inconsistent---the head was unboxed but the
tail was boxed.  This resulted in numerous needless copies and
also made the borrow check unhappy, because the head tended to be
stored in mutable memory.
2012-05-21 09:37:34 -07:00
Niko Matsakis
1ad5f7d2c1 make list based on boxes 2012-05-21 06:18:12 -07:00
Erick Tryzelaar
24cfe29a8a std: Fix a typo 2012-05-19 10:08:44 -07:00
Erick Tryzelaar
e7ca3e4db0 expose tzset 2012-05-19 10:08:43 -07:00
Niko Matsakis
bfde2ba524 port smallintmap over to dvec
also: add a non-operator-overloaded method for [] to work around #2378
2012-05-18 20:00:51 -07:00
Niko Matsakis
35f6f37453 avoid modifying the variable we are alting over 2012-05-18 20:00:50 -07:00
Niko Matsakis
c9edc0f0a1 introduce a few copies here and there 2012-05-18 20:00:50 -07:00
Niko Matsakis
f9aef928ca purge ufind 2012-05-18 20:00:50 -07:00
Eric Holk
0eed37da29 Using const vector slices for more vec functions. 2012-05-18 16:55:42 -07:00
Brian Anderson
0f20cae37f std: Don't copy hash key until we must 2012-05-18 16:50:16 -07:00
Eric Holk
3c48759a56 Added a method to convert sets to vectors. 2012-05-17 12:00:50 -07:00
Lindsey Kuper
b8880e3254 Remove be keyword.
Closes #2227.
2012-05-15 10:41:14 -07:00
Tim Chevalier
2830bc3d31 Comment only: Annotate FIXMEs in std::time 2012-05-03 17:55:23 -07:00
Tim Chevalier
82d4fe3967 Write unicode::icu::UCHAR_INVALID_CODE as -1, removing a FIXME 2012-05-03 17:45:06 -07:00
Tim Chevalier
97c0b3848d Comments only: annotate more FIXMEs in libstd 2012-05-03 17:45:06 -07:00
Tim Chevalier
ca3a9f83f4 Annotate more FIXMES in libstd (comments only) 2012-05-03 15:36:47 -07:00
Tim Chevalier
f029e1f486 Annotate FIXMEs in std::bitv, and remove a FIXME
Changed a while loop into a for loop in std::bitv::equal. Yay!
2012-05-03 15:26:22 -07:00
Brian Anderson
8d9f67003a std: Do less work in the timer stress tests 2012-05-02 12:03:21 -07:00
Brian Anderson
36f7ace839 Merge pull request #2322 from bkircher/fix-getopts-docs
Fix getopts docs
2012-05-01 10:30:39 -07:00
Benjamin Kircher
1a19309d91 std: Fix example in getopts module docs
Issue #1833.
2012-05-01 04:55:19 +02:00
Benjamin Kircher
22254c3b48 std: Fix typo in getopts doc attribute 2012-05-01 04:12:17 +02:00
Brian Anderson
46cc11ea88 core: Serialize all access to the environment using a weak global task 2012-04-30 17:34:29 -07:00
Brian Anderson
c01d05f18d std: Add 2 timer stress tests 2012-04-28 14:13:36 -07:00
Jeff Olson
caab57586a rt/std: whitespace cleanup + work on hl/global_loop docs 2012-04-27 22:19:30 -07:00
Jeff Olson
92e88e4e2c std: another stab at a race-free global loop implementation
seems to hold up pretty well.

uv::hl API is affected.. had to do work on tests and std::timer code that
leverages the global loop/high_level_loop API.

see test_stress_gl_uv_global_loop_high_level_global_timer for a stress
example.. it takes a while to run, but it exits cleanly (something I could
never accomplish with earlier iterations of the global loop)
2012-04-27 22:19:30 -07:00
Jeff Olson
474e7e5e0d std: get rid of some un-needed rustrt native fns for the global loop 2012-04-27 22:19:30 -07:00
Jeff Olson
fbaba0f404 std: add ll::loop_refcount binding for uv_loop_refcount 2012-04-27 22:19:30 -07:00
Brian Anderson
7eec6eb2bb std: Add FIXME about time tests 2012-04-26 13:54:01 -07:00
Ted Horst
340dbcfdc8 temporary hack to make testing std::time reliable 2012-04-26 13:52:29 -07:00
Graydon Hoare
753b683939 More slice use in vec, io, str, ebml, metadata encoder and decoder. 2012-04-25 17:19:36 -07:00
Marijn Haverbeke
9f99c3263b Rewrite exhaustiveness checker
Issue #2111
2012-04-25 09:15:17 +02:00
Marijn Haverbeke
9053f54498 Move map iface over to more for-friendly iteration methods 2012-04-23 15:18:19 +02:00
Brian Anderson
bef5cd8e45 std: Export sort::le 2012-04-21 13:45:20 -07:00
Jeff Olson
f855682bed std: ignore tests that use high_level_loop
until race issue with (most likely) refcount scheme is sorted out
2012-04-20 16:46:50 -07:00
Jeff Olson
707391edbc std: add timer::recv_timeout() and whitespace cleanup 2012-04-20 15:23:23 -07:00
Jeff Olson
7ac8c3081c std: add std::timer and timer::delayed_send and timer::sleep
.. leveraging std::uv, we have:
timer::delayed_send - send a value over a provided channel after the
timeout has passed
timer::sleep - block the current task for the specified period

both of these fns (and everything that goes in timer.rs) leverage the
uv_timer_* API
2012-04-20 15:23:23 -07:00
Jeff Olson
a1c43cc7c9 std: dump old std::uv API.. move remaining tests into uv::ll 2012-04-20 15:23:23 -07:00
Jeff Olson
791ea3466d std::uv : cleanup and an isolated test for hand-rolled high_level_loops 2012-04-20 15:23:23 -07:00
Jeff Olson
e02057c5a5 std: fail if exiting hl_loop has unref_handles at weaken_task exit 2012-04-20 15:23:23 -07:00
Jeff Olson
a9db0c9efe whitespace cleanup 2012-04-20 15:23:23 -07:00
Jeff Olson
a045e63639 std: get_monitor_task_gl() is global_loop::get() default 2012-04-20 15:23:23 -07:00
Jeff Olson
e15f1d5cad std: refactor global_loop::get.. make it reusable 2012-04-20 15:23:23 -07:00
Jeff Olson
afb35f752f fix uv_timer_t size in 32bit linux and windows
.. fixes issue, in previous commit, with global loop test hanging on
32bit linux (this was because the struct was too small, so (presumably),
the data member was garbled.. yippy)
2012-04-20 15:23:23 -07:00
Jeff Olson
83ae83c3b3 uv::hl::get_global_loop() -> uv::global_loop::get()
- moved global loop tests, as well.. will add tests in uv_hl that encompass
rolling your own high_level_loop via uv::hl::run_high_level_loop()
- also whitespace cleanups and misc warning cleanup..
- doesn't work on 32bit linux
2012-04-20 15:23:22 -07:00
Jeff Olson
253fad7788 replace impl of globa_async_handle with one using atomic compare-and-swap 2012-04-20 15:23:22 -07:00
Jeff Olson
728f92604a fix a race in global loop test; unref_handle now takes a close_cb 2012-04-20 15:23:22 -07:00
Jeff Olson
9a5d1974dc don't use ::malloc for initializing the global_async_handle in rust_kernel 2012-04-20 15:23:22 -07:00
Jeff Olson
f21d25b54c make weak task that runs libuv loop unsupervised 2012-04-20 15:23:22 -07:00
Jeff Olson
e0f110aa12 clean and trying the global loop test as two separate loop lifetimes..
.. seeing an occasional valgrind/barf spew on some invalid read/writes..
need to investigate further.. i think its related to my poor citizen
conduct, re: pointers stashed in rust_kernel..
2012-04-20 15:23:22 -07:00
Jeff Olson
31ba223c26 end-to-end impl of global loop w/ high-level ref counting.. needs work
- starting/stoping the loop based on client work is functioning, correctly
- the issue appears to be that, when the process is about to exit, the
signal to let weak tasks know that they need to exit isn't getting fired.
2012-04-20 15:23:22 -07:00
Jeff Olson
e6f6a8ced4 tweaking rust getter/setters for libuv data to use generics 2012-04-20 15:23:22 -07:00
Jeff Olson
12f2f4c15c rt: whitespace cleanup for existing libuv integration 2012-04-20 15:23:22 -07:00
Jeff Olson
e604c15df1 bindings to get/set data field on uv_loop_t* and debug log cleanup 2012-04-20 15:23:21 -07:00
Jeff Olson
bf99a3aa93 adding low-level uv_timer_* stuff to libuv bindings 2012-04-20 15:23:21 -07:00
Jeff Olson
3d004c6df8 making brson's req. cleanups in #2134 plus change printf to LOG in c++ 2012-04-20 15:23:21 -07:00
Graydon Hoare
956bc773c6 Fix [] on str to exclude the trailing null. 2012-04-18 17:50:58 -07:00
Marijn Haverbeke
a65af017ca Remove tri.rs and four.rs
Closes #1892
2012-04-18 17:21:39 +02:00
Haitao Li
39c5e06526 Revert "libstd: Handle test results in serial"
This reverts commit 828d0677c4.
2012-04-13 18:34:45 +08:00
Haitao Li
2955ecd13c Revert "libstd: Colorify test results when run in parallel"
This reverts commit 7b3cb05311.
2012-04-13 18:34:41 +08:00
Haitao Li
7b3cb05311 libstd: Colorify test results when run in parallel
Closes #782
2012-04-12 17:33:07 +08:00
Haitao Li
828d0677c4 libstd: Handle test results in serial
Issue #782
2012-04-12 17:33:01 +08:00
Jeff Olson
52e084b92a ignore tcp server/client test on linux 32bit, pending #2064
also println->log(debug,) and assorted cleanup ahead of merge to master
2012-04-06 15:35:50 -07:00
Jeff Olson
82f8d8cb2a removing some unneeded native fn mappingsin uv.rs and misc clean
.. 32bit linux issues persist.
2012-04-06 15:35:50 -07:00
Jeff Olson
6b349f3d11 experimenting with a different uv_buf_init impl to placate 32bit linux 2012-04-06 15:35:50 -07:00
Jeff Olson
6189a0814b whitespace cleanup in uv_* 2012-04-06 15:35:50 -07:00
Jeff Olson
ed3c8610c3 adding 32bit-unix struct struct size differences 2012-04-06 15:35:50 -07:00
Jeff Olson
79269ea064 fixing some libuv stuff that leaked through the rebase 2012-04-06 15:35:50 -07:00
Jeff Olson
b39a43cd5c adding uv_hl module and some doc work 2012-04-06 15:35:50 -07:00
Jeff Olson
7c0fed469f rename uv::direct:: to uv::ll:: and put into its own crate 2012-04-06 15:35:50 -07:00
Jeff Olson
f18991d900 getting rid of ip4 port byval test... 2064 workarounds in place, for now 2012-04-06 15:35:50 -07:00
Jeff Olson
b712e5e132 line length fixes for make check 2012-04-06 15:35:49 -07:00
Jeff Olson
55143bb14c docs tweak for uv module 2012-04-06 15:35:49 -07:00
Jeff Olson
26addfdd81 fix size of uv_async_t on windows. is this the cause of the libuv segfault? 2012-04-06 15:35:49 -07:00
Jeff Olson
2b606ae5f3 add libuv error msg helpers.. flushing out windows tcp issue. 2012-04-06 15:35:49 -07:00
Jeff Olson
2c26cf7f96 add low-level uv_async bindings for use in tcp test 2012-04-06 15:35:49 -07:00
Jeff Olson
7176321685 refactored the tcp request and server tests into 1 test using loopback
..plus whitespace cleanup for make check
2012-04-06 15:35:49 -07:00
Jeff Olson
922ed6f947 hello world test for a tcp server in libuv
.. im now going to refactor the tcp request and server tests to utilize
each other, so no more external network ugliness
2012-04-06 15:35:49 -07:00
Jeff Olson
85e26eff6a fixing libuv stuff in win32 (see #2064) .. pass sockaddr_in by-ref, for now 2012-04-06 15:35:49 -07:00
Jeff Olson
ab1efb900e fixed unix uv struct err from prev commit, also starting uv docs 2012-04-06 15:35:49 -07:00
Jeff Olson
fcc973b5ac massaging out struct-size differences between unix and win32 2012-04-06 15:35:49 -07:00
Jeff Olson
1eff88f434 win32 tweaks 2012-04-06 15:35:48 -07:00
Jeff Olson
9ad67e8c14 test_uv_tcp_request() fully working on linux
.. up next: windows!
.. impl'd uv::direct::read_stop() and uv::direct::close() to wrap things up
.. demonstrated sending data out of the uv_read_cb via a channel (which
we block on to recv all of it, complete w/ EOF notification) that is
read from after the loop exits.
.. helpers to read the guts of a uv_buf_t
.. an idea im kicking around: starting to pile up all of these hideous
data accessor functions in uv::direct .. I might make impl/iface pairs
for the various uv_* types that I'm using, in order to encapsulate those
data access functions and, perhaps, make the access look a little cleaner
(it still won't be straight field access, but it'll be a lot better)
.. formatting cleanup to satisfy make check
2012-04-06 15:35:48 -07:00
Jeff Olson
877747d0ac wired up uv_read_start and some helper funcs around uv_alloc_cb tasks 2012-04-06 15:35:48 -07:00
Jeff Olson
e0193dac6e uv_buf_t's for uv_write() passed by-val .. no more mallocs or ptr cop-outs
so we're now adhering the libuv C api and passing structs by-val where
it is expected, instead of pulling pointer trickery (or worse having to
malloc structs in c++ to be passed back to rust and then into C again)
2012-04-06 15:35:48 -07:00
Jeff Olson
e5ccc76bc4 fixed by-val from rust->c, use ++ sigil in native fn sig <-- NEVAR FORGET
have to use ++ sigil in rust-side extern fn decls in order to have rust
actually copy the struct, by value, onto the C stack. gotcha, indeed.

also adding a helper method to verify/remind how to pass a struct by-val
into C... check out the rust fn sig for rust_uv_ip4_test_verify_port_val()
for more infos
2012-04-06 15:35:48 -07:00
Jeff Olson
43c82bdb45 fixed passing in uv_buf_t ptr array in uv_write.. return status 0
ways to go, still..
2012-04-06 15:35:48 -07:00
Jeff Olson
f179029296 uv_write works, buffer passing still broke, can get sockaddr_in by val
.. but passing sockaddr_in by val back to C is broken, still passing by
ptr
.. the uv_write_cb is processed, but we have a status -1.. there is
also valgrind spew.. so buf passing is broken, still.
2012-04-06 15:35:48 -07:00
Jeff Olson
05e2c131c4 changing ctypes:: to libc:: and impl of uv::direct::write() 2012-04-06 15:35:48 -07:00
Jeff Olson
af08aba573 some more stuff for libuv dealing w/ 1402.. should go away soon 2012-04-06 15:35:48 -07:00
Jeff Olson
3817ba7578 adding uv::direct and beginning to work out tcp request case
lots of changes, here.. should've commited sooner.
- added uv::direct module that contains rust fns that map, neatly, to
the libuv c library as much as possible. they operate on ptrs to libuv
structs mapped in rust, as much as possible (there are some notable
exceptions). these uv::direct fns should only take inputs from rust and,
as neccesary, translate them into C-friendly types and then pass to the
C functions. We want to them to return ints, as the libuv functions do,
so we can start tracking status.
- the notable exceptions for structs above is due to ref gh-1402, which
prevents us from passing structs, by value, across the Rust<->C barrier
(they turn to garbage, pretty much). So in the cases where we get back
by-val structs from C (uv_buf_init(), uv_ip4_addr(), uv_err_t in callbacks)
, we're going to use *ctypes::void (or just errnum ints for uv_err_t) until
gh-1402 is resolved.
- using crust functions, in these uv::direct fns, for callbacks from libuv,
will eschew uv_err_t, if possible, in favor a struct int.. if at all
possible (probably isn't.. hm.. i know libuv wants to eventually move to
replace uv_err_t with an int, as well.. so hm).
- started flushing out a big, gnarly test case to exercise the tcp request
side of the uv::direct functions. I'm at the point where, after the
connection is established, we write to the stream... when the writing is
done, we will read from it, then tear the whole thing down.

overall, it turns out that doing "close to the metal" interaction with
c libraries is painful (and more chatty) when orchestrated from rust. My
understanding is that not much, at all, is written in this fashion in the
existant core/std codebase.. malloc'ing in C has been preferred, from what
I've gathered. So we're treading new ground, here!
2012-04-06 15:35:48 -07:00