Skip to content

Commit

Permalink
Simpler workaround for bug graydon/rust#1286.
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Dec 15, 2011
1 parent da21ddc commit 9f72a3d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions zmq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,18 @@ obj new_socket(sock: @socket_res) {

// Accept connections on a socket.
fn bind(endpoint: str) -> result::t<(), error> {
_bind(sock, endpoint)
// Work around rust bug #1286.
let sock = sock;
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_bind(sock.sock, b) });
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
}

// Connect a socket.
fn connect(endpoint: str) -> result::t<(), error> {
_connect(sock, endpoint)
// Work around rust bug #1286.
let sock = sock;
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_connect(sock.sock, b) });
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
}

fn send(data: [u8], flags: c_int) -> result::t<(), error> {
Expand Down Expand Up @@ -407,17 +413,6 @@ obj new_socket(sock: @socket_res) {
}
}

// Work around a bug by moving this out of an object.
fn _bind(sock: @socket_res, endpoint: str) -> result::t<(), error> {
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_bind(sock.sock, b) });
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
}

fn _connect(sock: @socket_res, endpoint: str) -> result::t<(), error> {
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_connect(sock.sock, b) });
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
}

// Convert a socket kind into the constant value.
fn socket_kind_to_i32(k: socket_kind) -> c_int {
alt k {
Expand Down

0 comments on commit 9f72a3d

Please sign in to comment.