+static void *send_thread (void *args __attribute__((unused))) /* {{{ */
+{
+ int sock;
+ unsigned short seed[3];
+ struct timespec ts;
+
+ unsigned long long local_events_sent = 0;
+
+ clock_gettime (CLOCK_REALTIME, &ts);
+ seed[2] = (unsigned short) (ts.tv_nsec);
+ seed[1] = (unsigned short) (ts.tv_nsec >> 16);
+ seed[0] = (unsigned short) (ts.tv_sec);
+
+ sock = sock_open ();
+
+ while (loop)
+ {
+ send_random_event (sock, seed);
+ local_events_sent++;
+ }
+
+ close (sock);
+
+ pthread_mutex_lock (&events_sent_lock);
+ events_sent += local_events_sent;
+ pthread_mutex_unlock (&events_sent_lock);
+
+ return (NULL);
+} /* }}} void *send_thread */
+
+static void run_threads (void) /* {{{ */
+{
+ pthread_t threads[conf_threads_num];
+ int i;
+
+ for (i = 0; i < conf_threads_num; i++)
+ {
+ int status;
+
+ status = pthread_create (&threads[i], /* attr = */ NULL,
+ send_thread, /* args = */ NULL);
+ if (status != 0)
+ {
+ fprintf (stderr, "pthread_create failed.");
+ abort ();
+ }
+ }
+
+ for (i = 0; i < conf_threads_num; i++)
+ pthread_join (threads[i], /* retval = */ NULL);
+} /* }}} void run_threads */
+
+static double timespec_diff (struct timespec const *ts0, /* {{{ */
+ struct timespec const *ts1)
+{
+ time_t diff_sec;
+ long diff_nsec;
+
+ diff_sec = ts1->tv_sec - ts0->tv_sec;
+ diff_nsec += ts1->tv_nsec - ts0->tv_nsec;
+
+ return ((double) diff_sec) + (((double) diff_nsec) / 1.0e9);
+} /* }}} double timespec_diff */
+