Skip to content

Commit

Permalink
only check pass when tls is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Sep 15, 2023
1 parent fdf19a7 commit 6fee88c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mirai
Type: Package
Title: Minimalist Async Evaluation Framework for R
Version: 0.9.1.9034
Version: 0.9.1.9035
Description: Lightweight parallel code execution and distributed computing.
Designed for simplicity, a 'mirai' evaluates an R expression asynchronously,
on local or network resources, resolving automatically upon completion.
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mirai 0.9.1.9034 (development)
# mirai 0.9.1.9035 (development)

* Uses L'Ecuyer-CMRG streams for safe and reproducible (in certain cases) random number generation across parallel processes (thanks @ltierney for discussion during R Project Sprint 2023).
+ `daemons()` gains the new argument 'seed' to set a random seed for generating these streams.
Expand Down
19 changes: 10 additions & 9 deletions R/mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,16 @@ dispatcher <- function(host, url = NULL, n = NULL, asyncdial = FALSE,
cv <- cv()
pipe_notify(sock, cv = cv, add = FALSE, remove = TRUE, flag = TRUE)
dial_and_sync_socket(sock = sock, url = host, asyncdial = asyncdial)
if (is.null(pass)) {
candidate <- Sys.getenv("NANO_TEMP")
if (nzchar(candidate)) {
Sys.unsetenv("NANO_TEMP")
pass <- candidate
if (length(tls)) {
if (is.null(pass)) {
candidate <- Sys.getenv("MIRAI_TEMP_VAR")
if (nzchar(candidate)) {
Sys.unsetenv("MIRAI_TEMP_VAR")
pass <- candidate
}
}
tls <- tls_config(server = tls, pass = pass)
}
if (length(tls)) tls <- tls_config(server = tls, pass = pass)

auto <- is.null(url)
vectorised <- length(url) == n
seq_n <- seq_len(n)
Expand Down Expand Up @@ -786,8 +787,8 @@ daemons <- function(n, url = NULL, dispatcher = TRUE, seed = NULL, tls = NULL, p
sock <- req_socket(urld)
sockc <- req_socket(urlc, resend = 0L)
if (is.character(pass)) {
on.exit(expr = Sys.unsetenv("NANO_TEMP"))
Sys.setenv(NANO_TEMP = pass)
on.exit(expr = Sys.unsetenv("MIRAI_TEMP_VAR"))
Sys.setenv(MIRAI_TEMP_VAR = pass)
}
launch_and_sync_daemon(sock = sock, urld, parse_dots(...), url, n, urlc, tls = tls)
init_monitor(sockc = sockc, envir = envir)
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ if (.Platform[["OS.type"]] != "windows") {
Sys.sleep(1L)
}
if (Sys.getenv("NOT_CRAN") == "true" && .Platform[["OS.type"]] != "windows") {
nanotesto(daemons(url = "wss://:0", token = TRUE))
nanotesto(daemons(url = "wss://:0", token = TRUE, pass = "test"))
nanotestn(launch_local(1L))
nanotest(grepl("CERTIFICATE", launch_remote(1L), fixed = TRUE))
nanotesterr(launch_local(0:1), "out of bounds")
Expand Down

0 comments on commit 6fee88c

Please sign in to comment.