Exemple #1
0
int slapi_apib_release(void **api)
{
	APIB_FEATURES *features;
	int ret;

	slapi_lock_mutex(((APIB_FEATURES*)(api[0]))->lock);
	
	ret = --(((APIB_FEATURES*)(api[0]))->refcount);
	
	if(((APIB_FEATURES*)(api[0]))->refcount == 0 && ((APIB_FEATURES*)(api[0]))->callback_on_zero)
	{
		/* save our stuff for when it gets zapped */
		features = (APIB_FEATURES*)api[0];

		if(0==((APIB_FEATURES*)(api[0]))->callback_on_zero(api)) /* this should deregister the interface */
		{
			slapi_unlock_mutex(features->lock);
			slapi_destroy_mutex(features->lock);
			slapi_ch_free((void **)&features);
		}
		else
			slapi_unlock_mutex(features->lock);
	}
	else
		slapi_unlock_mutex(((APIB_FEATURES*)(api[0]))->lock);

	return ret;
}
Exemple #2
0
int snmp_collator_stop()
{
	int err;

	if (snmp_collator_stopped) {
		return 0;
	}

	/* Abort any pending events */
	slapi_eq_cancel(snmp_eq_ctx);
	snmp_collator_stopped = 1;

	/* acquire the semaphore */
	snmp_collator_sem_wait();

	/* close the memory map */
	if ((err = agt_mclose_stats(hdl)) != 0)
	{
		fprintf(stderr, "Failed to close stats file (%s) (error = %d).",
			AGT_STATS_FILE, err);
	}

	if (remove(tmpstatsfile) != 0)
	{
		fprintf(stderr, "Failed to remove (%s) (error =  %d).\n",
		tmpstatsfile, errno);
	}

	/* close and delete semaphore */
	sem_close(stats_sem);
	sem_unlink(stats_sem_name);

	/* delete lock */
	slapi_destroy_mutex(interaction_table_mutex);

	/* stevross: I probably need to free stats too... make sure to add that later */

	return 0;
}