Exemplo n.º 1
0
int main (int argc, char **argv)
{
	memset(&application_info, 0, sizeof(application_info));
	decode_options(&application_info, argc, argv);

	workerthread hworker = workerthread_new(10);

	if(application_info.multicast_ip == NULL || application_info.multicast_port > 0) {
		usage("ipstrm-dump");
		exit(0);
	}

	conn* tsconn = join(application_info.multicast_ip, application_info.multicast_port);
	tsconn->filefd  = fopen(application_info.filepath, "wt+");
	KASSERT(tsconn->filefd > 0);

	workerthread_put_task(hworker, (void(*)(void*))receive_avstream, tsconn, NULL);

	for(;;) {
		sleep(1);
	}

	fclose(tsconn->filefd);
	return 0;
}
/** Launch threads until we have <b>n</b>. */
static int
threadpool_start_threads(threadpool_t *pool, int n)
{
  if (BUG(n < 0))
    return -1; // LCOV_EXCL_LINE
  if (n > MAX_THREADS)
    n = MAX_THREADS;

  tor_mutex_acquire(&pool->lock);

  if (pool->n_threads < n)
    pool->threads = tor_reallocarray(pool->threads,
                                     sizeof(workerthread_t*), n);

  while (pool->n_threads < n) {
    void *state = pool->new_thread_state_fn(pool->new_thread_state_arg);
    workerthread_t *thr = workerthread_new(state, pool, pool->reply_queue);

    if (!thr) {
      //LCOV_EXCL_START
      tor_assert_nonfatal_unreached();
      pool->free_thread_state_fn(state);
      tor_mutex_release(&pool->lock);
      return -1;
      //LCOV_EXCL_STOP
    }
    thr->index = pool->n_threads;
    pool->threads[pool->n_threads++] = thr;
  }
  tor_mutex_release(&pool->lock);

  return 0;
}
Exemplo n.º 3
0
/** Launch threads until we have <b>n</b>. */
static int
threadpool_start_threads(threadpool_t *pool, int n)
{
  if (n < 0)
    return -1;
  if (n > MAX_THREADS)
    n = MAX_THREADS;

  tor_mutex_acquire(&pool->lock);

  if (pool->n_threads < n)
    pool->threads = tor_reallocarray(pool->threads,
                                     sizeof(workerthread_t*), n);

  while (pool->n_threads < n) {
    void *state = pool->new_thread_state_fn(pool->new_thread_state_arg);
    workerthread_t *thr = workerthread_new(state, pool, pool->reply_queue);

    if (!thr) {
      tor_mutex_release(&pool->lock);
      return -1;
    }
    thr->index = pool->n_threads;
    pool->threads[pool->n_threads++] = thr;
  }
  tor_mutex_release(&pool->lock);

  return 0;
}
Exemplo n.º 4
0
int main (int argc, char **argv)
{
	workerthread hworker = workerthread_new(10);

	conn* tsconn = join(TEST_LIVE_STREAM_ADDR, TEST_LIVE_STREAM_PORT);
	tsconn->hdvbpsi = dvbpsi_AttachPAT(receive_pat, tsconn);
	workerthread_put_task(hworker, (void(*)(void*))receive_avstream, tsconn, NULL);

	for(;;) {
		sleep(1);
	}
	dvbpsi_DetachPAT(tsconn->hdvbpsi);

	return 0;
}