Пример #1
0
static VALUE
mol_by_mol(VALUE self, VALUE q_mol, VALUE t_mol)
{
  struct Query  query;
  struct Target target;
  struct State  state;
  VALUE result;

  target.max_length = 0;
  state.max_length = 0;

  query_setup(  q_mol, & query  );
  target_setup( t_mol, & target );

  state_allocate(& state, & query, & target);

  if(rb_block_given_p() == Qtrue){
    state_setup_block(& state);
  }
  else{
    state_setup(& state, & query, & target);
  }

  search_by_ullmann(& state, & query, & target);
  result = state_get_result(& state);

  query_free(& query);
  target_free(& target);
  state_free(& state);

  return result;
}
void target_dtor(struct target *t)
{
	t->allocmem = 0;
	t->initial_log = 0;

	if (t->event_fd != -1)
		close(t->event_fd);
	t->event_fd = -1;

	if (t->socket != UNKNOWN_FD)
		close(t->socket);
	t->socket = -1;

	thread_dtor(t->thread);
	target_free(t);
}
Пример #3
0
int
meta_back_db_destroy(
    Backend	*be
)
{
	struct metainfo *li;

	if ( be->be_private ) {
		int i;

		li = ( struct metainfo * )be->be_private;

		/*
		 * Destroy the connection tree
		 */
		ldap_pvt_thread_mutex_lock( &li->conn_mutex );

		if ( li->conntree ) {
			avl_free( li->conntree, conn_free );
		}

		/*
		 * Destroy the per-target stuff (assuming there's at
		 * least one ...)
		 */
		for ( i = 0; i < li->ntargets; i++ ) {
			target_free( li->targets[ i ] );
			free( li->targets[ i ] );
		}

		free( li->targets );

		ldap_pvt_thread_mutex_lock( &li->cache.mutex );
		if ( li->cache.tree ) {
			avl_free( li->cache.tree, meta_dncache_free );
		}
		
		ldap_pvt_thread_mutex_unlock( &li->cache.mutex );
		ldap_pvt_thread_mutex_destroy( &li->cache.mutex );

		ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
		ldap_pvt_thread_mutex_destroy( &li->conn_mutex );
	}

	free( be->be_private );
	return 0;
}
Пример #4
0
static retvalue target_initialize(/*@dependant@*/struct distribution *distribution, component_t component, architecture_t architecture, packagetype_t packagetype, get_version getversion, get_installdata getinstalldata, get_architecture getarchitecture, get_filekeys getfilekeys, get_checksums getchecksums, get_sourceandversion getsourceandversion, do_reoverride doreoverride, do_retrack doretrack, complete_checksums docomplete, /*@null@*//*@only@*/char *directory, /*@dependent@*/const struct exportmode *exportmode, bool readonly, bool noexport, /*@out@*/struct target **d) {
	struct target *t;

	assert(exportmode != NULL);
	if (FAILEDTOALLOC(directory))
		return RET_ERROR_OOM;

	t = zNEW(struct target);
	if (FAILEDTOALLOC(t)) {
		free(directory);
		return RET_ERROR_OOM;
	}
	t->relativedirectory = directory;
	t->exportmode = exportmode;
	t->distribution = distribution;
	assert (atom_defined(component));
	t->component = component;
	assert (atom_defined(architecture));
	t->architecture = architecture;
	assert (atom_defined(packagetype));
	t->packagetype = packagetype;
	t->identifier = calc_identifier(distribution->codename,
			component, architecture, packagetype);
	if (FAILEDTOALLOC(t->identifier)) {
		(void)target_free(t);
		return RET_ERROR_OOM;
	}
	t->getversion = getversion;
	t->getinstalldata = getinstalldata;
	t->getarchitecture = getarchitecture;
	t->getfilekeys = getfilekeys;
	t->getchecksums = getchecksums;
	t->getsourceandversion = getsourceandversion;
	t->doreoverride = doreoverride;
	t->doretrack = doretrack;
	t->completechecksums = docomplete;
	t->readonly = readonly;
	t->noexport = noexport;
	*d = t;
	return RET_OK;
}
struct target *target_ctor(void)
{
	struct target *t;

	t = target_malloc();
	if (t) {
		t->app_type = APP_TYPE_UNKNOWN;
		t->pid = UNKNOWN_PID;
		t->socket = UNKNOWN_FD;
		t->event_fd = UNKNOWN_FD;
		t->initial_log = 0;
		t->allocmem = 0;

		t->thread = thread_ctor();
		if (t->thread == NULL) {
			target_free(t);
			t = NULL;
		}
	}

	return t;
}
Пример #6
0
static retvalue distribution_free(struct distribution *distribution) {
	retvalue result, r;
	bool needsretrack = false;

	if (distribution != NULL) {
		free(distribution->suite);
		free(distribution->fakecomponentprefix);
		free(distribution->version);
		free(distribution->origin);
		free(distribution->notautomatic);
		free(distribution->butautomaticupgrades);
		free(distribution->label);
		free(distribution->description);
		free(distribution->deb_override);
		free(distribution->udeb_override);
		free(distribution->dsc_override);
		free(distribution->uploaders);
		atomlist_done(&distribution->udebcomponents);
		atomlist_done(&distribution->architectures);
		atomlist_done(&distribution->components);
		strlist_done(&distribution->signwith);
		strlist_done(&distribution->updates);
		strlist_done(&distribution->pulls);
		strlist_done(&distribution->alsoaccept);
		exportmode_done(&distribution->dsc);
		exportmode_done(&distribution->deb);
		exportmode_done(&distribution->udeb);
		atomlist_done(&distribution->contents_architectures);
		atomlist_done(&distribution->contents_components);
		atomlist_done(&distribution->contents_ucomponents);
		override_free(distribution->overrides.deb);
		override_free(distribution->overrides.udeb);
		override_free(distribution->overrides.dsc);
		logger_free(distribution->logger);
		if (distribution->uploaderslist != NULL) {
			uploaders_unlock(distribution->uploaderslist);
		}
		byhandhooks_free(distribution->byhandhooks);
		result = RET_OK;

		while (distribution->targets != NULL) {
			struct target *next = distribution->targets->next;

			if (distribution->targets->staletracking)
				needsretrack = true;

			r = target_free(distribution->targets);
			RET_UPDATE(result, r);
			distribution->targets = next;
		}
		if (distribution->tracking != dt_NONE && needsretrack) {
			fprintf(stderr,
"WARNING: Tracking data of '%s' might have become out of date.\n"
"Consider running retrack to avoid getting funny effects.\n",
					distribution->codename);
		}
		free(distribution->codename);
		free(distribution);
		return result;
	} else
		return RET_OK;
}
Пример #7
0
int
meta_back_db_destroy(
	Backend		*be,
	ConfigReply	*cr )
{
	metainfo_t	*mi;

	if ( be->be_private ) {
		int i;

		mi = ( metainfo_t * )be->be_private;

		/*
		 * Destroy the connection tree
		 */
		ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );

		if ( mi->mi_conninfo.lai_tree ) {
			avl_free( mi->mi_conninfo.lai_tree, meta_back_conn_free );
		}
		for ( i = LDAP_BACK_PCONN_FIRST; i < LDAP_BACK_PCONN_LAST; i++ ) {
			while ( !LDAP_TAILQ_EMPTY( &mi->mi_conn_priv[ i ].mic_priv ) ) {
				metaconn_t	*mc = LDAP_TAILQ_FIRST( &mi->mi_conn_priv[ i ].mic_priv );

				LDAP_TAILQ_REMOVE( &mi->mi_conn_priv[ i ].mic_priv, mc, mc_q );
				meta_back_conn_free( mc );
			}
		}

		/*
		 * Destroy the per-target stuff (assuming there's at
		 * least one ...)
		 */
		if ( mi->mi_targets != NULL ) {
			for ( i = 0; i < mi->mi_ntargets; i++ ) {
				metatarget_t	*mt = mi->mi_targets[ i ];

				if ( META_BACK_TGT_QUARANTINE( mt ) ) {
					if ( mt->mt_quarantine.ri_num != mi->mi_quarantine.ri_num )
					{
						mi->mi_ldap_extra->retry_info_destroy( &mt->mt_quarantine );
					}

					ldap_pvt_thread_mutex_destroy( &mt->mt_quarantine_mutex );
				}

				target_free( mt );
			}

			free( mi->mi_targets );
		}

		ldap_pvt_thread_mutex_lock( &mi->mi_cache.mutex );
		if ( mi->mi_cache.tree ) {
			avl_free( mi->mi_cache.tree, meta_dncache_free );
		}
		
		ldap_pvt_thread_mutex_unlock( &mi->mi_cache.mutex );
		ldap_pvt_thread_mutex_destroy( &mi->mi_cache.mutex );

		ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
		ldap_pvt_thread_mutex_destroy( &mi->mi_conninfo.lai_mutex );

		if ( mi->mi_candidates != NULL ) {
			ber_memfree_x( mi->mi_candidates, NULL );
		}

		if ( META_BACK_QUARANTINE( mi ) ) {
			mi->mi_ldap_extra->retry_info_destroy( &mi->mi_quarantine );
		}
	}

	free( be->be_private );
	return 0;
}