[nanomsg] Re: "ipc_stress test disabled" etc.

  • From: Ark Degtiarov <adegtiarov@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Thu, 6 Nov 2014 21:15:50 -0500

Hi Martin,

just revisited the code... as you know, it tries to start 1 server and 10
client threads.

Which, along with main() makes 12 threads all together.

Barring specialized embedded cases, which (mainstream?) platforms, may I
ask, would impose such low limit on threads per process?
Is there a way for me to get it for testing? Xen-friendly VM if possible?

In mean time, here's a proposed way to extend NN API:

index 36038dc..e2a982a 100644
--- a/src/utils/thread_posix.inc
+++ b/src/utils/thread_posix.inc
@@ -36,13 +36,13 @@ static void *nn_thread_main_routine (void *arg)
     return NULL;
 }

-void nn_thread_init (struct nn_thread *self,
+int nn_thread_create (struct nn_thread *self,
     nn_thread_routine *routine, void *arg)
 {
-    int rc;
+    int rc, rc_create;
     sigset_t new_sigmask;
     sigset_t old_sigmask;
-
+
     /*  No signals should be processed by this thread. The library doesn't
         use signals and thus all the signals should be delivered to
application
         threads, not to worker threads. */
@@ -53,13 +53,28 @@ void nn_thread_init (struct nn_thread *self,

     self->routine = routine;
     self->arg = arg;
-    rc = pthread_create (&self->handle, NULL, nn_thread_main_routine,
+    rc_create = pthread_create (&self->handle, NULL,
nn_thread_main_routine,
         (void*) self);
-    errnum_assert (rc == 0, rc);

     /*  Restore signal set to what it was before. */
     rc = pthread_sigmask (SIG_SETMASK, &old_sigmask, NULL);
     errnum_assert (rc == 0, rc);
+
+    if(rc_create < 0) {
+        errno = -rc_create;
+        return -1;
+    }
+
+    return rc_create;
+}
+
+void nn_thread_init (struct nn_thread *self,
+    nn_thread_routine *routine, void *arg)
+{
+    int rc;
+
+    rc = nn_thread_create(self, routine, arg);
+    errnum_assert (rc == 0, rc);
 }

 void nn_thread_term (struct nn_thread *self)


diff --git a/src/utils/thread.h b/src/utils/thread.h
index 0d31c6c..a88f4eb 100644
--- a/src/utils/thread.h
+++ b/src/utils/thread.h
@@ -33,6 +33,8 @@ typedef void (nn_thread_routine) (void*);
 #include "thread_posix.h"
 #endif

+int nn_thread_create (struct nn_thread *self,
+    nn_thread_routine *routine, void *arg);
 void nn_thread_init (struct nn_thread *self,
     nn_thread_routine *routine, void *arg);
 void nn_thread_term (struct nn_thread *self);

Best,

--Ark


On Thu, Nov 6, 2014 at 12:59 AM, Martin Sustrik <sustrik@xxxxxxxxxx> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> If you prefer to do it that way, go for it. Just keep in mind that
> errors inside nanomsg are reported as negitve numbers:
>
>     return -EAGAIN;
>
> Martin
>
> On 06/11/14 06:41, Ark Degtiarov wrote:
> > Will you object to something like that?
> >
> > On Nov 6, 2014 12:39 AM, "Martin Sustrik" <sustrik@xxxxxxxxxx
> > <mailto:sustrik@xxxxxxxxxx>> wrote:
> >
> > On 06/11/14 06:33, Ark Degtiarov wrote:
> >> Or gracefully stop creating new threads on 1st error.
> >
> > Yes. That's an option. However, it would require to change
> > nn_thread class to return this specific error rather than abort.
> >
> > Martin
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
>
> iQEcBAEBAgAGBQJUWw5OAAoJENTpVjxCNN9YhukH/2RWmTHhZUiWPY+XeUKfRcEc
> Vc6X1ZaWOx2CHSDpMnBR1tKBGvLkp6Qv6H00DeVExHNQmq8Feeex/o8W0TjryRts
> mtSy2JnXLSQqVDTbUW2M7r9ut+XCZFMhJ96QXVPbMfF+RsyZNwONx7k/DvKxiRJQ
> y27/ewIT+3siU2N+h/YWigTuwjbPUCm1ilCpA3IdgN959lvXnoNFgDz2YorG/A9B
> SZdMQprl1O2qJcUqBc0DYz65GqO5DD8radEv/A7VsnNetzJc+zGLlYBd6uZptyJr
> 0TpsQrifIjd+x1Bv2h1G0nl1LlGYloOUF2gktW8nXVqxmUC1yRCBp0D0PRDqiO8=
> =83ww
> -----END PGP SIGNATURE-----
>
>

Other related posts: