Skip to content

Commit

Permalink
refresh messenger()
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 3, 2023
1 parent 60c35cb commit ca3b4e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 0 additions & 2 deletions R/messenger.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ messenger <- function(url, auth = NULL) {
cat(sprintf("%*s > %s\n", nchar(data), "", format.POSIXct(Sys.time())), file = stdout())
}

invisible()

}

# nocov end
15 changes: 7 additions & 8 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ SEXP rnng_messenger(SEXP url) {
nng_socket *sock = R_Calloc(1, nng_socket);
nano_listener *lp;
nano_dialer *dp;
uint8_t dialer = 0;
int xc;
int xc, dialer = 0;
SEXP socket, con;

xc = nng_pair0_open(sock);
Expand All @@ -160,7 +159,12 @@ SEXP rnng_messenger(SEXP url) {
}
lp = R_Calloc(1, nano_listener);
xc = nng_listen(*sock, up, &lp->list, 0);
if (xc == 10 || xc == 15) {
if (xc) {
if (xc != 10 && xc != 15) {
R_Free(lp);
R_Free(sock);
ERROR_OUT(xc);
}
R_Free(lp);
dp = R_Calloc(1, nano_dialer);
xc = nng_dial(*sock, up, &dp->dial, 0);
Expand All @@ -170,11 +174,6 @@ SEXP rnng_messenger(SEXP url) {
ERROR_OUT(xc);
}
dialer = 1;

} else if (xc) {
R_Free(lp);
R_Free(sock);
ERROR_OUT(xc);
}

PROTECT(socket = R_MakeExternalPtr(sock, nano_SocketSymbol, R_NilValue));
Expand Down

0 comments on commit ca3b4e1

Please sign in to comment.