Skip to content

Commit

Permalink
compact code
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Oct 26, 2023
1 parent a26bdb8 commit d105399
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: nanonext
Type: Package
Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library
Version: 0.10.2.9011
Version: 0.10.2.9012
Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is
a socket library providing high-performance scalability protocols, a
cross-platform standard for messaging and communications. Serves as a
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# nanonext 0.10.2.9011 (development)
# nanonext 0.10.2.9012 (development)

#### New Features

Expand Down
20 changes: 8 additions & 12 deletions src/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,16 +861,13 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) {
nano_serialize_next(&buf, data); break;
}

if ((xc = nng_msg_alloc(&msg, 0))) {
NANO_FREE(buf);
goto exitlevel1;
}
if ((xc = nng_msg_alloc(&msg, 0)))
goto exitlevel2;

if ((xc = nng_msg_append(msg, buf.buf, buf.cur)) ||
(xc = nng_aio_alloc(&saio->aio, saio_complete, saio))) {
nng_msg_free(msg);
NANO_FREE(buf);
goto exitlevel1;
goto exitlevel2;
}

nng_aio_set_msg(saio->aio, msg);
Expand All @@ -897,16 +894,13 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) {
nano_serialize_next(&buf, data); break;
}

if ((xc = nng_msg_alloc(&msg, 0))) {
NANO_FREE(buf);
goto exitlevel1;
}
if ((xc = nng_msg_alloc(&msg, 0)))
goto exitlevel2;

if ((xc = nng_msg_append(msg, buf.buf, buf.cur)) ||
(xc = nng_aio_alloc(&saio->aio, saio_complete, saio))) {
nng_msg_free(msg);
NANO_FREE(buf);
goto exitlevel1;
goto exitlevel2;
}

nng_aio_set_msg(saio->aio, msg);
Expand Down Expand Up @@ -968,6 +962,8 @@ SEXP rnng_send_aio(SEXP con, SEXP data, SEXP mode, SEXP timeout, SEXP clo) {
UNPROTECT(3);
return env;

exitlevel2:
NANO_FREE(buf);
exitlevel1:
R_Free(saio);
return mk_error_data(-xc);
Expand Down
1 change: 1 addition & 0 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ nanotest(is_error_value(sess) || length(transact(sess)) == 3L)
nanotest(is_error_value(sess) || close(sess) == 0L)
nanotesterr(transact(sess), "ncurlSession")
nanotestw(is_error_value(ncurl_session("https://i")))
nanotesterr(ncurl("https://www.cam.ac.uk/", tls = "wrong"), "valid TLS")
nanotesterr(stream(dial = "wss://127.0.0.1:5555"))
nanotesterr(stream(dial = "wss://127.0.0.1:5555", tls = "wrong"), "valid TLS")
nanotesterr(stream(listen = "errorValue3"), "argument")
Expand Down

0 comments on commit d105399

Please sign in to comment.