Skip to content

Commit

Permalink
do not load Rserve dylib into an embedded Rserve instance (fixes #11)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-u committed Aug 26, 2013
1 parent 777c7cc commit 1271d41
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
useDynLib(Rserve, run_Rserve)
export(Rserve, self.ctrlEval, self.ctrlSource, self.oobSend, self.oobMessage, run.Rserve)
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
---------------------------

1.8-0 (under development)
o avoid duplicate symbols by not loading the Rserve dylib
inside an embedded Rserve instance. This avoid issues
of calling the wrong symbols, but it implies that
run.Rserve() can no longer be used from within a
child proces of an embedded Rserve instance (which
you really don't want to do anyway).


1.7-3 2013-08-21
o the handling of server configuration modes has been
Expand Down
4 changes: 3 additions & 1 deletion R/conn.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ Rserve <- function(debug=FALSE, port, args=NULL, quote=(length(args) > 1), wait,
invisible(system(cmd, wait=wait, ...))
}

run.Rserve <- function(..., config.file="/etc/Rserve.conf")
run.Rserve <- function(..., config.file="/etc/Rserve.conf") {
if (is.null(run_Rserve)) stop("Runnig inside an embedded Rserve instance - starting Rserve recursively is not supported")
.Call(run_Rserve, as.character(config.file), sapply(list(...), as.character))
}

self.ctrlEval <- function(expr) {
if (!is.loaded("Rserve_ctrlEval")) stop("This command can only be run inside Rserve with r-control enabled")
Expand Down
19 changes: 19 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## we have to load the dylib/so/DLL by hand
## because it is optional in case we're loaded
## into an embedded Rserve instance

.register <- c("Rserve_ctrlEval", "Rserve_ctrlSource",
"Rserve_oobSend", "Rserve_oobMsg",
"Rserve_oc_register", "run_Rserve")

.onLoad <- function(libname, pkgname) {
env <- environment(.onLoad)
## unless we are runnning in an embedded Rserve (which provides
## registration in the "(embedding)" domain)
## we have to load the package dylib
if (!isTRUE(tryCatch(getNativeSymbolInfo(.register[1L])$package[["name"]] == "(embedding)",
error=function(...) FALSE)))
library.dynam(pkgname, pkgname, libname)
for (i in .register)
env[[i]] <- tryCatch(getNativeSymbolInfo(i), error=function(...) NULL)
}

0 comments on commit 1271d41

Please sign in to comment.