I first tried to add a new file signal-alarm.cc and build additional libsignal.so from it. So only small part of signal.cc would be in new library. It was enough to move to new libsignal.so just itimer::* class/code, itimer_real/virt variables and all code which uses itimer_real/virt variables (alarm(), cancel_this_thread_alarm() etc). But to get also tst-kill.so pass (when multiple instances of tst-kill.so are run in parallel in different namespaces), I should also moved sigaction() and kill() - and then very little (nothing?) would be left in signal.cc.
So at the end I made new patch, which just uses whole, unmodified signal.cc

Justin

On 03/08/2017 08:22 AM, Justin Cinkelj wrote:
Before patch, netperf netserver.so and netperf.so could not be run in
the same VM. The netserver reports "error starting alarm timer,
ret 3 errno 28".

The patch make alarm (and also signals) per namespace specific, in the
wat as environ was made per namespace specific in
wat -> way
e93af8d3622ba1cf491ba12c780f05bb447de8ac and
1d3645b6c1a119ea34e1a3dca6ae814d4902905f.

Signed-off-by: Justin Cinkelj <[email protected]>
---
  Makefile           |  9 ++++++++-
  core/app.cc        | 10 ++++++++++
  include/osv/app.hh |  2 ++
  usr.manifest.skel  |  1 +
  4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6846c5e..d982864 100644
--- a/Makefile
+++ b/Makefile
@@ -926,6 +926,7 @@ libc =
  musl =
  environ_libc =
  environ_musl =
+signal_libc =
ifeq ($(arch),x64)
  musl_arch = x86_64
@@ -995,6 +996,8 @@ environ_musl += env/putenv.c
  environ_musl += env/setenv.c
  environ_musl += env/unsetenv.c
+signal_libc += signal.cc
+
  musl += ctype/__ctype_b_loc.o
musl += errno/strerror.o
@@ -1830,10 +1833,14 @@ $(out)/bsd/%.o: COMMON += -DSMP 
-D'__FBSDID(__str__)=extern int __bogus__'
environ_sources = $(addprefix libc/, $(environ_libc))
  environ_sources += $(addprefix musl/src/, $(environ_musl))
+signal_sources = $(addprefix libc/, $(signal_libc))
$(out)/libenviron.so: $(environ_sources)
        $(makedir)
         $(call quiet, $(CC) $(CFLAGS) -shared -o $(out)/libenviron.so 
$(environ_sources), CC libenviron.so)
+$(out)/libsignal.so: $(signal_sources)
+       $(makedir)
+        $(call quiet, $(CXX) $(CXXFLAGS) -shared -o $(out)/libsignal.so 
$(signal_sources), CXX libsignal.so)
bootfs_manifest ?= bootfs.manifest.skel @@ -1847,7 +1854,7 @@ $(bootfs_manifest_dep): phony
        fi
$(out)/bootfs.bin: scripts/mkbootfs.py $(bootfs_manifest) $(bootfs_manifest_dep) $(tools:%=$(out)/%) \
-               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so
+               $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so 
$(out)/libsignal.so
        $(call quiet, olddir=`pwd`; cd $(out); $$olddir/scripts/mkbootfs.py -o 
bootfs.bin -d bootfs.bin.d -m $$olddir/$(bootfs_manifest) \
                -D jdkbase=$(jdkbase) -D gccbase=$(gccbase) -D \
                glibcbase=$(glibcbase) -D miscbase=$(miscbase), MKBOOTFS $@)
diff --git a/core/app.cc b/core/app.cc
index d623a61..b800522 100644
--- a/core/app.cc
+++ b/core/app.cc
@@ -161,6 +161,7 @@ application::application(const std::string& command,
          if (new_program) {
              this->new_program();
              clone_osv_environ();
+            clone_osv_signal();
              current_program = _program.get();
          } else {
              // Do it in a separate branch because elf::get_program() would not
@@ -449,6 +450,15 @@ elf::program *application::program() {
  }
+void application::clone_osv_signal()
+{
+    _libsignal = _program->get_library("libsignal.so");
+    if (!_libsignal) {
+        abort("could not load libsignal.so\n");
+        return;
+    }
+}
+
  void application::clone_osv_environ()
  {
      _libenviron = _program->get_library("libenviron.so");
diff --git a/include/osv/app.hh b/include/osv/app.hh
index 83e017e..d301551 100644
--- a/include/osv/app.hh
+++ b/include/osv/app.hh
@@ -185,6 +185,7 @@ public:
      elf::program *program();
  private:
      void new_program();
+    void clone_osv_signal();
      void clone_osv_environ();
      void set_environ(const std::string &key, const std::string &value,
                       bool new_program);
@@ -213,6 +214,7 @@ private:
      mutex _termination_mutex;
      std::shared_ptr<elf::object> _lib;
      std::shared_ptr<elf::object> _libenviron;
+    std::shared_ptr<elf::object> _libsignal;
      main_func_t* _main;
      void (*_entry_point)();
      static app_registry apps;
diff --git a/usr.manifest.skel b/usr.manifest.skel
index 583bdfe..73f58c1 100644
--- a/usr.manifest.skel
+++ b/usr.manifest.skel
@@ -1,5 +1,6 @@
  [manifest]
  /libenviron.so: libenviron.so
+/libsignal.so: libsignal.so
  /zpool.so: zpool.so
  /libzfs.so: libzfs.so
  /libuutil.so: libuutil.so

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to