Skip to content

Commit 9f72a3d

Browse files
committed
Simpler workaround for bug graydon/rust#1286.
1 parent da21ddc commit 9f72a3d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

zmq.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,18 @@ obj new_socket(sock: @socket_res) {
356356

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

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

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

410-
// Work around a bug by moving this out of an object.
411-
fn _bind(sock: @socket_res, endpoint: str) -> result::t<(), error> {
412-
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_bind(sock.sock, b) });
413-
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
414-
}
415-
416-
fn _connect(sock: @socket_res, endpoint: str) -> result::t<(), error> {
417-
let rc = str::as_buf(endpoint, { |b| libzmq::zmq_connect(sock.sock, b) });
418-
if rc == -1i32 { err(errno_to_error()) } else { ok(()) }
419-
}
420-
421416
// Convert a socket kind into the constant value.
422417
fn socket_kind_to_i32(k: socket_kind) -> c_int {
423418
alt k {

0 commit comments

Comments
 (0)