Skip to content

Commit

Permalink
cleaner error when unloading fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoohafkan committed Aug 5, 2019
1 parent 008ade6 commit af240bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 6 additions & 4 deletions R/connect.r
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ hql_unload = function() {
if (hql_is_loaded()) {
dllpath = normalizePath(file.path(hql.paths$install,
hql.paths$dll), mustWork = TRUE)
lapply(dllpath, dyn.unload)
if (hql_is_loaded()) {
stop("HDFql DLLs could not be unloaded.")
}
for (dll in dllpath) {
dyn.unload(dll)
if (dll %in% sapply(getLoadedDLLs(), function(x) normalizePath(x[["path"]], mustWork = FALSE))) {
stop("Error unloading HDFql shared library object ", dll)
}
}
rm(list = "wrapper", envir = hql)
}
invisible(NULL)
Expand Down
10 changes: 8 additions & 2 deletions R/zzz.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
}

.onUnload = function(libpath) {
hql_unload()
tryCatch(hql_unload(),
error = function(e) {
warning(packageName(), " could not be unloaded cleanly\n", e$message)
})
}

.onDetach = function(libpath) {
hql_unload()
tryCatch(hql_unload(),
error = function(e) {
warning(packageName(), " could not be unloaded cleanly\n", e$message)
})
}

0 comments on commit af240bf

Please sign in to comment.