about summary refs log tree commit diff
path: root/src/libstd/io/net/unix.rs
AgeCommit message (Collapse)AuthorLines
2014-09-16Rename std::io::net::unix to std::io::net::pipe.Jonas Hietala-802/+0
Renamed as we may support pipes for other platforms. Closes #12093 [breaking-change]
2014-08-28auto merge of #16626 : ruud-v-a/rust/duration-reform, r=brsonbors-1/+1
This changes the internal representation of `Duration` from days: i32, secs: i32, nanos: u32 to secs: i64, nanos: i32 This resolves #16466. Note that `nanos` is an `i32` and not `u32` as suggested, because `i32` is easier to deal with, and it is not exposed anyway. Some methods now take `i64` instead of `i32` due to the increased range. Some methods, like `num_milliseconds`, now return an `Option<i64>` instead of `i64`, because the range of `Duration` is now larger than e.g. 2^63 milliseconds. A few remarks: - Negating `MIN` is impossible. I chose to return `MAX` as `-MIN`, but it is one nanosecond less than the actual negation. Is this the desired behaviour? - In `std::io::timer`, some functions accept a `Duration`, which is internally converted into a number of milliseconds. However, the range of `Duration` is now larger than 2^64 milliseconds. There is already a FIXME in the file that this should be addressed (without a ticket number though). I chose to silently use 0 ms if the duration is too long. Is that right, as long as the backend still uses milliseconds? - Negative durations are not formatted correctly, but they were not formatted correctly before either.
2014-08-24native: clone/close_accept for win32 pipesAlex Crichton-0/+2
This commits takes a similar strategy to the previous commit to implement close_accept and clone for the native win32 pipes implementation. Closes #15595
2014-08-24native: Implement clone/close_accept for unixAlex Crichton-0/+95
This commits implements {Tcp,Unix}Acceptor::{clone,close_accept} methods for unix. A windows implementation is coming in a later commit. The clone implementation is based on atomic reference counting (as with all other clones), and the close_accept implementation is based on selecting on a self-pipe which signals that a close has been seen.
2014-08-21libstd: Limit Duration range to i64 milliseconds.Ruud van Asseldonk-7/+1
This enables `num_milliseconds` to return an `i64` again instead of `Option<i64>`, because it is guaranteed not to overflow. The Duration range is now rougly 300e6 years (positive and negative), whereas it was 300e9 years previously. To put these numbers in perspective, 300e9 years is about 21 times the age of the universe (according to Wolfram|Alpha). 300e6 years is about 1/15 of the age of the earth (according to Wolfram|Alpha).
2014-08-20libstd: Refactor Duration.Ruud van Asseldonk-2/+8
This changes the internal representation of `Duration` from days: i32, secs: i32, nanos: u32 to secs: i64, nanos: i32 This resolves #16466. Some methods now take `i64` instead of `i32` due to the increased range. Some methods, like `num_milliseconds`, now return an `Option<i64>` instead of `i64`, because the range of `Duration` is now larger than e.g. 2^63 milliseconds.
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-6/+1
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-13std: Fix build errorsBrian Anderson-1/+1
2014-08-13std: Make connect_timeout return Err on zero durationBrian Anderson-8/+10
[breaking-change]
2014-08-13std: connect_timeout requires a positive DurationBrian Anderson-1/+19
This is only breaking if you were previously specifying a duration of zero for some mysterious reason. [breaking-change]
2014-08-13std: Make the TCP/UDP connect_timeout methods take DurationBrian Anderson-4/+5
[breaking-change]
2014-07-13Stabilization for `owned` (now `boxed`) and `cell`Aaron Turon-1/+1
This PR is the outcome of the library stabilization meeting for the `liballoc::owned` and `libcore::cell` modules. Aside from the stability attributes, there are a few breaking changes: * The `owned` modules is now named `boxed`, to better represent its contents. (`box` was unavailable, since it's a keyword.) This will help avoid the misconception that `Box` plays a special role wrt ownership. * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move` method is renamed to `downcast`, in both cases to improve clarity. * The recently-added `AnySendOwnExt` extension trait is removed; it was not being used and is unnecessary. [breaking-change]
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-5/+5
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-15Register new snapshotsAlex Crichton-3/+3
2014-06-06std: Deal with fallout of rtio changesAlex Crichton-10/+22
2014-05-08std: Mark timeout methods experimentalAlex Crichton-0/+3
This was intended as part of the I/O timeouts commit, but it was mistakenly forgotten. The type of the timeout argument is not guaranteed to remain constant into the future.
2014-05-07native: Implement timeouts for windows pipesAlex Crichton-1/+6
This is the last remaining networkig object to implement timeouts for. This takes advantage of the CancelIo function and the already existing asynchronous I/O functionality of pipes.
2014-05-07std: Add I/O timeouts to networking objectsAlex Crichton-14/+139
These timeouts all follow the same pattern as established by the timeouts on acceptors. There are three methods: set_timeout, set_read_timeout, and set_write_timeout. Each of these sets a point in the future after which operations will time out. Timeouts with cloned objects are a little trickier. Each object is viewed as having its own timeout, unaffected by other objects' timeouts. Additionally, timeouts do not propagate when a stream is cloned or when a cloned stream has its timeouts modified. This commit is just the public interface which will be exposed for timeouts, the implementation will come in later commits.
2014-05-07std: Add close_{read,write}() methods to I/OAlex Crichton-11/+91
Two new methods were added to TcpStream and UnixStream: fn close_read(&mut self) -> IoResult<()>; fn close_write(&mut self) -> IoResult<()>; These two methods map to shutdown()'s behavior (the system call on unix), closing the reading or writing half of a duplex stream. These methods are primarily added to allow waking up a pending read in another task. By closing the reading half of a connection, all pending readers will be woken up and will return with EndOfFile. The close_write() method was added for symmetry with close_read(), and I imagine that it will be quite useful at some point. Implementation-wise, librustuv got the short end of the stick this time. The native versions just delegate to the shutdown() syscall (easy). The uv versions can leverage uv_shutdown() for tcp/unix streams, but only for closing the writing half. Closing the reading half is done through some careful dancing to wake up a pending reader. As usual, windows likes to be different from unix. The windows implementation uses shutdown() for sockets, but shutdown() is not available for named pipes. Instead, CancelIoEx was used with same fancy synchronization to make sure everyone knows what's up. cc #11165
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-3/+4
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-04-24std: Add timeouts to unix connect/acceptAlex Crichton-1/+90
This adds support for connecting to a unix socket with a timeout (a named pipe on windows), and accepting a connection with a timeout. The goal is to bring unix pipes/named sockets back in line with TCP support for timeouts. Similarly to the TCP sockets, all methods are marked #[experimental] due to uncertainty about the type of the timeout argument. This internally involved a good bit of refactoring to share as much code as possible between TCP servers and pipe servers, but the core implementation did not change drastically as part of this commit. cc #13523
2014-04-22native: Unlink unix socket paths on dropAlex Crichton-0/+16
This prevents unix sockets from remaining on the system all over the place, and more closely mirrors the behavior of libuv and windows pipes.
2014-04-14Use new attribute syntax in python files in src/etc too (#13478)Manish Goregaokar-2/+2
2014-04-08Register new snapshotsAlex Crichton-1/+1
2014-03-31std: Switch field privacy as necessaryAlex Crichton-3/+3
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-27Fix fallout of removing default boundsAlex Crichton-6/+7
This is all purely fallout of getting the previous commit to compile.
2014-03-25libstd: Document the following modules:Patrick Walton-0/+4
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-24/+22
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-02-28std: Improve some I/O documentationAlex Crichton-0/+2
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-27std: Small cleanup and test improvementAlex Crichton-6/+10
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-24Correctly ignore some tests on windowsAlex Crichton-1/+1
These two tests are notoriously flaky on the windows bots right now, so I'm ignoring them until I can investigate them some more. The truncate_works test has been flaky for quite some time, but it has gotten much worse recently. The test_exists test has been flaky since the recent std::run rewrite landed. Finally, the "unix pipe" test failure is a recent discovery on the try bots. I haven't seen this failing much, but better safe than sorry! cc #12516
2014-02-16Implement named pipes for windows, touch up unixAlex Crichton-41/+60
* Implementation of pipe_win32 filled out for libnative * Reorganize pipes to be clone-able * Fix a few file descriptor leaks on error * Factor out some common code into shared functions * Make use of the if_ok!() macro for less indentation Closes #11201
2014-02-14Fix all code examplesAlex Crichton-5/+8
2014-02-11Test fixes and rebase conflictsAlex Crichton-1/+1
2014-02-05Implement clone() for TCP/UDP/Unix socketsAlex Crichton-0/+96
This is part of the overall strategy I would like to take when approaching issue #11165. The only two I/O objects that reasonably want to be "split" are the network stream objects. Everything else can be "split" by just creating another version. The initial idea I had was the literally split the object into a reader and a writer half, but that would just introduce lots of clutter with extra interfaces that were a little unnnecssary, or it would return a ~Reader and a ~Writer which means you couldn't access things like the remote peer name or local socket name. The solution I found to be nicer was to just clone the stream itself. The clone is just a clone of the handle, nothing fancy going on at the kernel level. Conceptually I found this very easy to wrap my head around (everything else supports clone()), and it solved the "split" problem at the same time. The cloning support is pretty specific per platform/lib combination: * native/win32 - uses some specific WSA apis to clone the SOCKET handle * native/unix - uses dup() to get another file descriptor * green/all - This is where things get interesting. When we support full clones of a handle, this implies that we're allowing simultaneous writes and reads to happen. It turns out that libuv doesn't support two simultaneous reads or writes of the same object. It does support *one* read and *one* write at the same time, however. Some extra infrastructure was added to just block concurrent writers/readers until the previous read/write operation was completed. I've added tests to the tcp/unix modules to make sure that this functionality is supported everywhere.
2014-02-03std: Fixing all documentationAlex Crichton-10/+0
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Fix tests with io_error usageAlex Crichton-34/+24
2014-02-03std: Remove io::io_errorAlex Crichton-34/+26
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-30Remove Times traitBrendan Zabarauskas-4/+4
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-4/+4
2014-01-09Remove eof() from io::ReaderAlex Crichton-1/+0
2013-12-25Test fixes and rebase conflictsAlex Crichton-1/+2
* vec::raw::to_ptr is gone * Pausible => Pausable * Removing @ * Calling the main task "<main>" * Removing unused imports * Removing unused mut * Bringing some libextra tests up to date * Allowing compiletest to work at stage0 * Fixing the bootstrap-from-c rmake tests * assert => rtassert in a few cases * printing to stderr instead of stdout in fail!()
2013-12-24std: Get stdtest all passing againAlex Crichton-2/+3
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24std: Expose that LocalIo may not always be availableAlex Crichton-16/+6
It is not the case that all programs will always be able to acquire an instance of the LocalIo borrow, so this commit exposes this limitation by returning Option<LocalIo> from LocalIo::borrow(). At the same time, a helper method LocalIo::maybe_raise() has been added in order to encapsulate the functionality of raising on io_error if there is on local I/O available.
2013-12-24std: Delete rt::testAlex Crichton-55/+43
This module contains many M:N specific concepts. This will no longer be available with libgreen, and most functions aren't really that necessary today anyway. New testing primitives will be introduced as they become available for 1:1 and M:N. A new io::test module is introduced with the new ip4/ip6 address helpers to continue usage in io tests.
2013-12-17auto merge of #10863 : cadencemarseille/rust/patch-handle-ENOENT, r=alexcrichtonbors-1/+1
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-17Handle ENOENTCadence Marseille-1/+1
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-16Test fallout from std::comm rewriteAlex Crichton-2/+2
2013-12-16Fallout of rewriting std::commAlex Crichton-15/+10