Exemple #1
0
/**
 * rgaFree
 *
 *
 *
 */
void rgaFree(
    rgaRing_t       *ring)
{
    size_t UNUSED(base_sz);

    base_sz = ring->elt_sz * ring->cap;

#if YAF_RING_THREAD
    /* free conditions and mutex if present */
    if (ring->cnd_zero) {
        g_cond_free(ring->cnd_zero);
    }

    if (ring->cnd_full) {
        g_cond_free(ring->cnd_full);
    }

    if (ring->mtx) {
        g_mutex_free(ring->mtx);
    }
#endif

    /* free buffer */
    yg_slice_free1(base_sz, ring->base);

    /* free structure */
    yg_slice_free(rgaRing_t, ring);
}
Exemple #2
0
enum playlist_result
playlist_open_into_queue(const char *uri,
                         unsigned start_index, unsigned end_index,
                         struct playlist *dest, struct player_control *pc,
                         bool secure)
{
    GMutex *mutex = g_mutex_new();
    GCond *cond = g_cond_new();

    struct input_stream *is;
    struct playlist_provider *playlist =
    playlist_open_any(uri, mutex, cond, &is);
    if (playlist == NULL) {
        g_cond_free(cond);
        g_mutex_free(mutex);
        return PLAYLIST_RESULT_NO_SUCH_LIST;
    }

    enum playlist_result result =
        playlist_load_into_queue(uri, playlist, start_index, end_index,
                                 dest, pc, secure);
    playlist_plugin_close(playlist);

    if (is != NULL)
        input_stream_close(is);

    g_cond_free(cond);
    g_mutex_free(mutex);

    return result;
}
void
gst_aiur_stream_cache_finalize (GstAiurStreamCache * cache)
{
  if (cache->pad) {
    gst_object_unref (GST_OBJECT_CAST (cache->pad));
    cache->pad = NULL;
  }

  if (cache->adapter) {
    gst_adapter_clear (cache->adapter);
    gst_object_unref (cache->adapter);
    cache->adapter = NULL;
  }

  if (cache->produce_cond) {
    g_cond_free (cache->produce_cond);
    cache->produce_cond = NULL;
  }

  if (cache->consume_cond) {
    g_cond_free (cache->consume_cond);
    cache->consume_cond = NULL;
  }

  if (cache->mutex) {
    g_mutex_free (cache->mutex);
    cache->mutex = NULL;
  }
}
static void
gst_hls_demux_dispose (GObject * obj)
{
  GstHLSDemux *demux = GST_HLS_DEMUX (obj);

  g_cond_free (demux->fetcher_cond);
  g_mutex_free (demux->fetcher_lock);

  g_cond_free (demux->thread_cond);
  g_mutex_free (demux->thread_lock);

  if (GST_TASK_STATE (demux->task) != GST_TASK_STOPPED) {
    gst_task_stop (demux->task);
    gst_task_join (demux->task);
  }
  gst_object_unref (demux->task);
  g_static_rec_mutex_free (&demux->task_lock);

  gst_object_unref (demux->fetcher_bus);
  gst_object_unref (demux->fetcherpad);

  gst_hls_demux_reset (demux, TRUE);

  gst_object_unref (demux->download);

  G_OBJECT_CLASS (parent_class)->dispose (obj);
}
static void
gst_dshowaudiodec_finalize (GObject * object)
{
  GstDshowAudioDec *adec = (GstDshowAudioDec *) (object);

  if (adec->segment) {
    gst_segment_free (adec->segment);
    adec->segment = NULL;
  }

  if (adec->codec_data) {
    gst_buffer_unref (adec->codec_data);
    adec->codec_data = NULL;
  }

  /* signal the COM thread that it sould uninitialize COM */
  if (adec->comInitialized) {
    g_mutex_lock (adec->com_deinit_lock);
    g_cond_signal (adec->com_uninitialize);
    g_cond_wait (adec->com_uninitialized, adec->com_deinit_lock);
    g_mutex_unlock (adec->com_deinit_lock);
  }

  g_mutex_free (adec->com_init_lock);
  g_mutex_free (adec->com_deinit_lock);
  g_cond_free (adec->com_initialized);
  g_cond_free (adec->com_uninitialize);
  g_cond_free (adec->com_uninitialized);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_dshowvideodec_finalize (GObject * object)
{
  GstDshowVideoDec *vdec = (GstDshowVideoDec *) (object);

  if (vdec->segment) {
    gst_segment_free (vdec->segment);
    vdec->segment = NULL;
  }

  /* signal the COM thread that it sould uninitialize COM */
  if (vdec->comInitialized) {
    g_mutex_lock (vdec->com_deinit_lock);
    g_cond_signal (vdec->com_uninitialize);
    g_cond_wait (vdec->com_uninitialized, vdec->com_deinit_lock);
    g_mutex_unlock (vdec->com_deinit_lock);
  }

  g_mutex_free (vdec->com_init_lock);
  g_mutex_free (vdec->com_deinit_lock);
  g_cond_free (vdec->com_initialized);
  g_cond_free (vdec->com_uninitialize);
  g_cond_free (vdec->com_uninitialized);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
gst_decklink_sink_finalize (GObject * object)
{
  GstDecklinkSink *decklinksink;

  g_return_if_fail (GST_IS_DECKLINK_SINK (object));
  decklinksink = GST_DECKLINK_SINK (object);

  /* clean up object here */
  g_cond_free (decklinksink->cond);
  g_mutex_free (decklinksink->mutex);
  g_mutex_free (decklinksink->audio_mutex);

  delete decklinksink->callback;

#ifdef _MSC_VER
  /* signal the COM thread that it should uninitialize COM */
  if (decklinksink->comInitialized) {
    g_mutex_lock (decklinksink->com_deinit_lock);
    g_cond_signal (decklinksink->com_uninitialize);
    g_cond_wait (decklinksink->com_uninitialized, decklinksink->com_deinit_lock);
    g_mutex_unlock (decklinksink->com_deinit_lock);
  }

  g_mutex_free (decklinksink->com_init_lock);
  g_mutex_free (decklinksink->com_deinit_lock);
  g_cond_free (decklinksink->com_initialized);
  g_cond_free (decklinksink->com_uninitialize);
  g_cond_free (decklinksink->com_uninitialized);
#endif /* _MSC_VER */

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Exemple #8
0
static void
gst_spot_src_finalize (GObject * object)
{
  GstSpotSrc *spot;

  spot = GST_SPOT_SRC (object);

  /* make thread quit */
  g_mutex_lock (spot->process_events_mutex);
  spot->keep_spotify_thread = FALSE;
  GST_CAT_DEBUG_OBJECT (gst_spot_src_debug_threads, spot, "Broadcast process_events_cond");
  g_cond_broadcast (spot->process_events_cond);
  g_mutex_unlock (spot->process_events_mutex);
  g_thread_join (spot->process_events_thread);
  
  /* free user variables */
  g_free (spot->user);
  g_free (spot->pass);
  g_free (spot->uri);

  g_free (spot->format);
  g_list_free (spot->spot_works);

  g_cond_free (spot->process_events_cond);
  g_mutex_free (spot->process_events_mutex);

  g_mutex_free (GST_SPOT_SRC_ADAPTER_MUTEX (spot));
  g_cond_free (GST_SPOT_SRC_ADAPTER_COND (spot));
  g_object_unref (GST_SPOT_SRC_ADAPTER (spot));

  G_OBJECT_CLASS (parent_class)->finalize (object);

}
static void
rejilla_async_task_manager_finalize (GObject *object)
{
	RejillaAsyncTaskManager *cobj;

	cobj = REJILLA_ASYNC_TASK_MANAGER (object);

	/* THIS DOESN'T FREE ALL IT'S JUST BETTER THAN NOTHING
	 * THE DERIVED OBJECT MUST ENSURE TO EMPTY EVERYTHING 
	 * ESPECIALLY DATA ASSOCIATED WITH THE CONTEXTS */

	/* stop the threads first */
	g_mutex_lock (cobj->priv->lock);
	cobj->priv->cancelled = TRUE;

	/* remove all the waiting tasks */
	g_slist_foreach (cobj->priv->waiting_tasks,
			 (GFunc) g_free,
			 NULL);
	g_slist_free (cobj->priv->waiting_tasks);
	cobj->priv->waiting_tasks = NULL;

	/* terminate all sleeping threads */
	g_cond_broadcast (cobj->priv->new_task);

	/* Now we wait for the active thread queue to return */
	while (cobj->priv->num_threads)
		g_cond_wait (cobj->priv->thread_finished, cobj->priv->lock);

	g_mutex_unlock (cobj->priv->lock);

	if (cobj->priv->task_finished) {
		g_cond_free (cobj->priv->task_finished);
		cobj->priv->task_finished = NULL;
	}

	if (cobj->priv->thread_finished) {
		g_cond_free (cobj->priv->thread_finished);
		cobj->priv->thread_finished = NULL;
	}

	if (cobj->priv->new_task) {
		g_cond_free (cobj->priv->new_task);
		cobj->priv->new_task = NULL;
	}

	if (cobj->priv->lock) {
		g_mutex_free (cobj->priv->lock);
		cobj->priv->lock = NULL;
	}

	g_free (cobj->priv);
	G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
 * Free all memory used by the ringbuffer
 */
void
xmms_ringbuf_destroy (xmms_ringbuf_t *ringbuf)
{
	g_return_if_fail (ringbuf);

	g_cond_free (ringbuf->eos_cond);
	g_cond_free (ringbuf->used_cond);
	g_cond_free (ringbuf->free_cond);

	g_queue_free (ringbuf->hotspots);
	g_free (ringbuf->buffer);
	g_free (ringbuf);
}
Exemple #11
0
static void
finalize_impl(
    GObject * obj_self)
{
    XferSourceRecovery *self = XFER_SOURCE_RECOVERY(obj_self);

    if (self->conn)
	g_object_unref(self->conn);
    if (self->device)
	g_object_unref(self->device);

    g_cond_free(self->start_part_cond);
    g_cond_free(self->abort_cond);
    g_mutex_free(self->start_part_mutex);
}
Exemple #12
0
static void
afamqp_dd_free(LogPipe *d)
{
  AMQPDestDriver *self = (AMQPDestDriver *) d;

  g_mutex_free(self->suspend_mutex);
  g_mutex_free(self->queue_mutex);
  g_cond_free(self->writer_thread_wakeup_cond);

  if (self->queue)
    log_queue_unref(self->queue);

  g_free(self->exchange);
  g_free(self->exchange_type);
  log_template_unref(self->routing_key_template);
  log_template_unref(self->body_template);
  g_free(self->user);
  g_free(self->password);
  g_free(self->host);
  g_free(self->vhost);
  g_free(self->entries);
  if (self->vp)
    value_pairs_free(self->vp);
  log_dest_driver_free(d);
}
Exemple #13
0
void
ec_lock_free_regardless (ECLock *self)
{
    g_mutex_free (self->state_mutex);

    g_cond_free (self->state_cv);

    g_static_rw_lock_free (self->lock);
    g_free (self->lock);

    g_static_mutex_free (self->trace_lock);
    g_free (self->trace_lock);

    g_hash_table_destroy (self->readers);

    g_hash_table_destroy (self->traced_threads);

    g_hash_table_destroy (self->thread_names);

    g_static_rw_lock_free (self->free_lock);
    // FIIXME: I'm not certain now where I got the idea that we need
    // g_free as well as g_static_rw_lock_free, though I have a hazy
    // idea I may have looked at the source once upon a time to
    // determine this.
    g_free (self->free_lock);

    g_free (self);
}
Exemple #14
0
static void webkitVideoSinkDispose(GObject* object)
{
    WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(object);
    WebKitVideoSinkPrivate* priv = sink->priv;

    if (priv->dataCondition) {
#if GLIB_CHECK_VERSION(2, 31, 0)
        g_cond_clear(priv->dataCondition);
        delete priv->dataCondition;
#else
        g_cond_free(priv->dataCondition);
#endif
        priv->dataCondition = 0;
    }

    if (priv->bufferMutex) {
#if GLIB_CHECK_VERSION(2, 31, 0)
        g_mutex_clear(priv->bufferMutex);
        delete priv->bufferMutex;
#else
        g_mutex_free(priv->bufferMutex);
#endif
        priv->bufferMutex = 0;
    }

    G_OBJECT_CLASS(parent_class)->dispose(object);
}
Exemple #15
0
static void
bus_registry_destroy (BusRegistry *registry)
{
#ifdef G_THREADS_ENABLED
    if (registry->thread) {
        g_mutex_lock (registry->mutex);
        registry->thread_running = FALSE;
        g_mutex_unlock (registry->mutex);
        g_cond_signal (registry->cond);
        g_thread_join (registry->thread);
        registry->thread = NULL;
    }
#endif

    bus_registry_remove_all (registry);

    g_hash_table_destroy (registry->engine_table);
    registry->engine_table = NULL;

#ifdef G_THREADS_ENABLED
    g_cond_free (registry->cond);
    registry->cond = NULL;

    g_mutex_free (registry->mutex);
    registry->mutex = NULL;
#endif

    IBUS_OBJECT_CLASS (bus_registry_parent_class)->destroy (IBUS_OBJECT (registry));
}
Exemple #16
0
void
g_sem_free (GSem * sem)
{
  g_cond_free (sem->condition);
  g_mutex_free (sem->mutex);
  g_free (sem);
}
static gboolean
invoke_async_auth (const gchar *callback_name, gconstpointer in,
		   gsize in_size, gpointer out, gsize out_size)
{
	MountThreadAuth auth;
	memset (&auth, 0, sizeof(auth));
	auth.callback = callback_name;
	auth.in_args = in;
	auth.in_size = in_size;
	auth.out_args = out;
	auth.out_size = out_size;
	auth.invoked = FALSE;
	auth.mutex = g_mutex_new ();
	auth.cond = g_cond_new ();

	DEBUG_MOUNT (("mount invoking auth callback: %s\n", callback_name));

	g_mutex_lock (auth.mutex);
	g_idle_add_full (G_PRIORITY_HIGH_IDLE, (GSourceFunc)invoke_async_auth_cb, &auth, NULL);
	g_cond_wait (auth.cond, auth.mutex);

	g_mutex_unlock (auth.mutex);
	g_mutex_free (auth.mutex);
	g_cond_free (auth.cond);

	DEBUG_MOUNT (("mount invoked auth callback: %s %d\n", callback_name, auth.invoked));
	
	return auth.invoked;
}
Exemple #18
0
static void
cleanup (void)
{
  GST_DEBUG ("cleanup_queue");

  gst_check_drop_buffers ();

  drop_events ();

  g_cond_free (underrun_cond);
  underrun_cond = NULL;
  g_mutex_free (underrun_mutex);
  underrun_mutex = NULL;

  if (mysinkpad != NULL) {
    gst_pad_set_active (mysinkpad, FALSE);
    gst_check_teardown_sink_pad (queue);
  }

  gst_pad_set_active (mysrcpad, FALSE);
  gst_check_teardown_src_pad (queue);

  gst_check_teardown_element (queue);
  queue = NULL;
}
Exemple #19
0
/**
 * gst_buffer_straw_stop_pipeline:
 * @bin: the pipeline previously started via gst_buffer_straw_start_pipeline()
 * @pad: the pad previously passed to gst_buffer_straw_start_pipeline()
 *
 * Set @bin to #GST_STATE_NULL and release resource allocated in
 * gst_buffer_straw_start_pipeline().
 *
 * You must have previously called gst_buffer_straw_start_pipeline() on
 * @pipeline and @pad.
 */
void
gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad)
{
  GstStateChangeReturn ret;

  g_mutex_lock (lock);
  if (buf)
    gst_buffer_unref (buf);
  buf = NULL;
  gst_pad_remove_buffer_probe (pad, (guint) id);
  id = 0;
  g_cond_signal (cond);
  g_mutex_unlock (lock);

  ret = gst_element_set_state (bin, GST_STATE_NULL);
  fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not stop test pipeline");
  if (ret == GST_STATE_CHANGE_ASYNC) {
    ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
    fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
  }

  g_mutex_lock (lock);
  if (buf)
    gst_buffer_unref (buf);
  buf = NULL;
  g_mutex_unlock (lock);

  g_mutex_free (lock);
  g_cond_free (cond);

  lock = NULL;
  cond = NULL;
}
void
gkd_gpg_agent_uninitialize (void)
{
	gboolean ret;

	g_assert (pkcs11_main_mutex);
	ret = g_mutex_trylock (pkcs11_main_mutex);
	g_assert (ret);

		g_assert (GCK_IS_SESSION (pkcs11_main_session));
		g_assert (!pkcs11_main_checked);
		g_object_unref (pkcs11_main_session);
		pkcs11_main_session = NULL;

	g_mutex_unlock (pkcs11_main_mutex);
	g_mutex_free (pkcs11_main_mutex);
	g_cond_free (pkcs11_main_cond);

	g_assert (pkcs11_module);
	g_object_unref (pkcs11_module);
	pkcs11_module = NULL;

	g_assert (cache_settings);
	g_object_unref (cache_settings);
	cache_settings = NULL;
}
static void
custom_data_free (CustomData *custom_data)
{
    g_mutex_free (custom_data->omx_state_mutex);
    g_cond_free (custom_data->omx_state_condition);
    g_free (custom_data);
}
Exemple #22
0
static void
xmms_output_destroy (xmms_object_t *object)
{
	xmms_output_t *output = (xmms_output_t *)object;

	output->monitor_volume_running = FALSE;
	if (output->monitor_volume_thread) {
		g_thread_join (output->monitor_volume_thread);
		output->monitor_volume_thread = NULL;
	}

	xmms_output_filler_state (output, FILLER_QUIT);
	g_thread_join (output->filler_thread);

	if (output->plugin) {
		xmms_output_plugin_method_destroy (output->plugin, output);
		xmms_object_unref (output->plugin);
	}

	xmms_object_unref (output->playlist);

	g_mutex_free (output->status_mutex);
	g_mutex_free (output->playtime_mutex);
	g_mutex_free (output->filler_mutex);
	g_cond_free (output->filler_state_cond);
	xmms_ringbuf_destroy (output->filler_buffer);

	xmms_ipc_broadcast_unregister ( XMMS_IPC_SIGNAL_OUTPUT_VOLUME_CHANGED);
	xmms_ipc_broadcast_unregister ( XMMS_IPC_SIGNAL_PLAYBACK_STATUS);
	xmms_ipc_broadcast_unregister ( XMMS_IPC_SIGNAL_OUTPUT_CURRENTID);
	xmms_ipc_signal_unregister (XMMS_IPC_SIGNAL_OUTPUT_PLAYTIME);
	xmms_ipc_object_unregister (XMMS_IPC_OBJECT_OUTPUT);
}
Exemple #23
0
Scheduler::~Scheduler() {
	XOJ_CHECK_TYPE(Scheduler);

	SDEBUG("Destroy scheduler\n", 0);

	if(this->jobRenderThreadTimerId) {
		g_source_remove(this->jobRenderThreadTimerId);
		this->jobRenderThreadTimerId = 0;
	}

	stop();

	g_mutex_free(this->jobQueueMutex);
	g_mutex_free(this->jobRunningMutex);

	g_mutex_free(this->schedulerMutex);

	g_mutex_free(this->blockRenderMutex);

	g_cond_free(this->jobQueueCond);

	Job * job = NULL;
	while (job = getNextJobUnlocked()) {
		job->unref();
	}

	if (this->blockRenderZoomTime) {
		g_free(this->blockRenderZoomTime);
	}

	XOJ_RELEASE_TYPE(Scheduler);
}
int closeGlobals(struct GLOBAL *global)
{
	g_free(global->videodevice);
	g_free(global->confPath);
	g_free(global->vidFPath[1]);
	g_free(global->imgFPath[1]);
	g_free(global->imgFPath[0]);
	g_free(global->vidFPath[0]);
	g_free(global->profile_FPath[1]);
	g_free(global->profile_FPath[0]);
	g_free(global->vidFPath);
	g_free(global->imgFPath);
	g_free(global->profile_FPath);
	g_free (global->WVcaption);
	g_free(global->imageinc_str);
	g_free(global->vidinc_str);
	g_free(global->vidfile);
	g_free(global->mode);
	g_free(global->Sound_IndexDev);
	g_mutex_free( global->mutex );
	g_cond_free( global->IO_cond);
	
	global->videodevice=NULL;
	global->confPath=NULL;
	global->vidfile=NULL;
	global->mode=NULL;
	if(global->jpeg) g_free(global->jpeg);
	global->jpeg=NULL;
	g_free(global);
	global=NULL;
	return (0);
}
Exemple #25
0
void audio_output_finish(struct audio_output *ao)
{
	audio_output_close(ao);

	assert(ao->fail_timer == NULL);

	if (ao->thread != NULL) {
		g_mutex_lock(ao->mutex);
		ao_command(ao, AO_COMMAND_KILL);
		g_mutex_unlock(ao->mutex);
		g_thread_join(ao->thread);
	}

	if (ao->mixer != NULL)
		mixer_free(ao->mixer);

	ao_plugin_finish(ao->plugin, ao->data);

	g_cond_free(ao->cond);
	g_mutex_free(ao->mutex);

	if (ao->replay_gain_filter != NULL)
		filter_free(ao->replay_gain_filter);

	if (ao->other_replay_gain_filter != NULL)
		filter_free(ao->other_replay_gain_filter);

	filter_free(ao->filter);

	pcm_buffer_deinit(&ao->cross_fade_buffer);
}
Exemple #26
0
static void
gst_bus_dispose (GObject * object)
{
  GstBus *bus;

  bus = GST_BUS (object);

  if (bus->queue) {
    GstMessage *message;

    g_mutex_lock (bus->queue_lock);
    do {
      message = g_queue_pop_head (bus->queue);
      if (message)
        gst_message_unref (message);
    } while (message != NULL);
    g_queue_free (bus->queue);
    bus->queue = NULL;
    g_mutex_unlock (bus->queue_lock);
    g_mutex_free (bus->queue_lock);
    bus->queue_lock = NULL;
    g_cond_free (bus->priv->queue_cond);
    bus->priv->queue_cond = NULL;
  }

  if (bus->priv->main_context) {
    g_main_context_unref (bus->priv->main_context);
    bus->priv->main_context = NULL;
  }

  G_OBJECT_CLASS (parent_class)->dispose (object);
}
static gboolean
gst_mio_video_src_perform (GstMIOVideoSrc * self, GstMIOCallback cb,
    gpointer data)
{
  GstMIOPerformCtx ctx;
  GSource *source;

  ctx.self = self;
  ctx.callback = cb;
  ctx.data = data;
  ctx.result = FALSE;

  ctx.mutex = g_mutex_new ();
  ctx.cond = g_cond_new ();
  ctx.finished = FALSE;

  source = g_idle_source_new ();
  g_source_set_callback (source, gst_mio_video_src_perform_proxy, &ctx, NULL);
  g_source_attach (source, self->dispatcher_ctx);

  g_mutex_lock (ctx.mutex);
  while (!ctx.finished)
    g_cond_wait (ctx.cond, ctx.mutex);
  g_mutex_unlock (ctx.mutex);

  g_source_destroy (source);
  g_source_unref (source);

  g_cond_free (ctx.cond);
  g_mutex_free (ctx.mutex);

  return ctx.result;
}
Exemple #28
0
static void
gst_vaapidecode_destroy(GstVaapiDecode *decode)
{
    if (decode->decoder) {
        gst_vaapi_decoder_put_buffer(decode->decoder, NULL);
        g_object_unref(decode->decoder);
        decode->decoder = NULL;
    }

    if (decode->decoder_caps) {
        gst_caps_unref(decode->decoder_caps);
        decode->decoder_caps = NULL;
    }

    if (decode->decoder_ready) {
        gst_vaapidecode_release(decode, NULL);
        g_cond_free(decode->decoder_ready);
        decode->decoder_ready = NULL;
    }

    if (decode->decoder_mutex) {
        g_mutex_free(decode->decoder_mutex);
        decode->decoder_mutex = NULL;
    }
}
Exemple #29
0
void glibcurl_cleanup() {
  D((stderr, "glibcurl_cleanup\n"));
  /* You must call curl_multi_remove_handle() and curl_easy_cleanup() for all
     requests before calling this. */
/*   assert(curlSrc->callPerform == 0); */

  /* All easy handles must be finished */

  /* Lock before accessing selectRunning/selectThread */
  g_mutex_lock(curlSrc->mutex);
  curlSrc->selectRunning = FALSE;
  while (curlSrc->selectThread != NULL) {
    g_mutex_unlock(curlSrc->mutex);
    g_thread_yield();
    g_cond_signal(curlSrc->cond); /* Make the select thread shut down */
    g_thread_yield();
    g_mutex_lock(curlSrc->mutex); /* Wait until it has shut down */
  }
  g_mutex_unlock(curlSrc->mutex);

  assert(curlSrc->selectThread == NULL);

  g_cond_free(curlSrc->cond);
  g_mutex_free(curlSrc->mutex);

  curl_multi_cleanup(curlSrc->multiHandle);
  curlSrc->multiHandle = 0;
  curl_global_cleanup();

  g_source_unref(&curlSrc->source);
  curlSrc = 0;
}
Exemple #30
0
/**
 * z_policy_thread_destroy:
 * @self: this
 *
 * Destructor of ZPolicyThread.
 * The embedded Python thread context (self->thread) will be cleared and 
 * deleted also, and if this thread was the last one running in the
 * interpreter instance, that will be stopped, too.
 */
void
z_policy_thread_destroy(ZPolicyThread *self)
{
  /* acquires the interpreter lock */

  if (self->policy->main_thread != self)
    {
      /* we are one of the secondary threads */
      z_python_lock();
      PyThreadState_Swap(self->thread);
      PyThreadState_Clear(self->thread);
      PyThreadState_Swap(NULL);
      PyThreadState_Delete(self->thread);
      z_python_unlock();
      z_policy_unref(self->policy);
    }
  else
    {
      /* we must be freed at last, when the policy is being destroyed */
      g_assert(self->policy->ref_cnt == 1);
      /* we are the main thread, destroy the interpreter */
      z_policy_purge(self->policy);
      PyEval_AcquireThread(self->thread);
      Py_EndInterpreter(self->thread);
      z_python_unlock();
    }
  g_mutex_free(self->startable_lock);
  g_cond_free(self->startable_signal);
  g_free(self);
}