Skip to content

Commit

Permalink
Delete preexisting dynamic library first (rusterlium#129)
Browse files Browse the repository at this point in the history
Fix rusterlium#128. Copying the build library on top of a preexisting build can
result in a segfault if a node is currently using the already-built library.
  • Loading branch information
evnu authored and hansihe committed Feb 7, 2018
1 parent 0c123f5 commit 607ce6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rustler_mix/lib/mix/tasks/compile.rustler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ defmodule Mix.Tasks.Compile.Rustler do
compiled_lib = Path.join([target_dir, Atom.to_string(build_mode), src_file])
destination_lib = Path.join(priv_dir(), dst_file)

# If the file exists already, we delete it first. This is to ensure that another
# process, which might have the library dynamically linked in, does not generate
# a segfault. By deleting it first, we ensure that the copy operation below does
# not write into the existing file.
File.rm(destination_lib)
File.cp!(compiled_lib, destination_lib)
end

Expand Down

0 comments on commit 607ce6b

Please sign in to comment.