Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
No more threads.
Vsevolod Stakhov committed 11 years ago
commit 796787c8e36f9d0a58e776113bf72a0b10ce3eb6
parent 7825ae5
4 files changed +3 -185
modified libpkg/Makefile.am
@@ -66,7 +66,7 @@ libpkg_la_LIBADD= $(top_builddir)/external/libucl.la \
			-lcrypto \
			-lm

-
libpkg_la_LDFLAGS=	-version-info @LIBPKG_SO_VERSION@ -pthread -Wl,--version-script=$(srcdir)/libpkg.ver
+
libpkg_la_LDFLAGS=	-version-info @LIBPKG_SO_VERSION@ -Wl,--version-script=$(srcdir)/libpkg.ver
lib_LTLIBRARIES=	libpkg.la libpkg_static.la
include_HEADERS=	pkg.h

@@ -88,7 +88,6 @@ noinst_HEADERS= private/db_upgrades.h \
			private/pkg_printf.h \
			private/pkgdb.h \
			private/repodb.h \
-
			private/thd_repo.h \
			private/utils.h

SUBDIRS = repo .

\ No newline at end of file
modified libpkg/pkg_repo_create.c
@@ -73,119 +73,6 @@ struct pkg_conflict_bulk {
	UT_hash_handle hh;
};

-
static void
-
pkg_read_pkg_file(void *data)
-
{
-
	struct thd_data *d = (struct thd_data*) data;
-
	struct pkg_result *r;
-
	struct pkg_manifest_key *keys = NULL;
-

-
	FTSENT *fts_ent = NULL;
-
	char fts_accpath[MAXPATHLEN];
-
	char fts_path[MAXPATHLEN];
-
	char fts_name[MAXPATHLEN];
-
	off_t st_size;
-
	int fts_info, flags;
-

-
	char *ext = NULL;
-
	char *pkg_path;
-

-
	pkg_manifest_keys_new(&keys);
-

-
	for (;;) {
-
		fts_ent = NULL;
-

-
		/*
-
		 * Get a file to read from.
-
		 * Copy the data we need from the fts entry localy because as soon as
-
		 * we unlock the fts_m mutex, we can not access it.
-
		 */
-
		pthread_mutex_lock(&d->fts_m);
-
		if (!d->stop)
-
			fts_ent = fts_read(d->fts);
-
		if (fts_ent != NULL) {
-
			strlcpy(fts_accpath, fts_ent->fts_accpath, sizeof(fts_accpath));
-
			strlcpy(fts_path, fts_ent->fts_path, sizeof(fts_path));
-
			strlcpy(fts_name, fts_ent->fts_name, sizeof(fts_name));
-
			st_size = fts_ent->fts_statp->st_size;
-
			fts_info = fts_ent->fts_info;
-
		}
-
		pthread_mutex_unlock(&d->fts_m);
-

-
		/* There is no more jobs, exit the main loop. */
-
		if (fts_ent == NULL)
-
			break;
-

-
		/* Skip everything that is not a file */
-
		if (fts_info != FTS_F)
-
			continue;
-

-
		ext = strrchr(fts_name, '.');
-

-
		if (ext == NULL)
-
			continue;
-

-
		if (strcmp(ext, ".tgz") != 0 &&
-
				strcmp(ext, ".tbz") != 0 &&
-
				strcmp(ext, ".txz") != 0 &&
-
				strcmp(ext, ".tar") != 0)
-
			continue;
-

-
		*ext = '\0';
-

-
		if (strcmp(fts_name, repo_db_archive) == 0 ||
-
			strcmp(fts_name, repo_packagesite_archive) == 0 ||
-
			strcmp(fts_name, repo_filesite_archive) == 0 ||
-
			strcmp(fts_name, repo_digests_archive) == 0 ||
-
			strcmp(fts_name, repo_conflicts_archive) == 0)
-
			continue;
-
		*ext = '.';
-

-
		pkg_path = fts_path;
-
		pkg_path += strlen(d->root_path);
-
		while (pkg_path[0] == '/')
-
			pkg_path++;
-

-
		r = calloc(1, sizeof(struct pkg_result));
-
		strlcpy(r->path, pkg_path, sizeof(r->path));
-

-
		if (d->read_files)
-
			flags = PKG_OPEN_MANIFEST_ONLY;
-
		else
-
			flags = PKG_OPEN_MANIFEST_ONLY | PKG_OPEN_MANIFEST_COMPACT;
-

-
		if (pkg_open(&r->pkg, fts_accpath, keys, flags) != EPKG_OK) {
-
			r->retcode = EPKG_WARN;
-
		} else {
-
			sha256_file(fts_accpath, r->cksum);
-
			pkg_set(r->pkg, PKG_CKSUM, r->cksum,
-
			    PKG_REPOPATH, pkg_path,
-
			    PKG_PKGSIZE, st_size);
-
		}
-

-

-
		/* Add result to the FIFO and notify */
-
		pthread_mutex_lock(&d->results_m);
-
		while (d->num_results >= d->max_results) {
-
			pthread_cond_wait(&d->has_room, &d->results_m);
-
		}
-
		DL_APPEND(d->results, r);
-
		d->num_results++;
-
		pthread_cond_signal(&d->has_result);
-
		pthread_mutex_unlock(&d->results_m);
-
	}
-

-
	/*
-
	 * This thread is about to exit.
-
	 * Notify the main thread that we are done.
-
	 */
-
	pthread_mutex_lock(&d->results_m);
-
	d->thd_finished++;
-
	pthread_cond_signal(&d->has_result);
-
	pthread_mutex_unlock(&d->results_m);
-
	pkg_manifest_keys_free(keys);
-
}
-

static int
pkg_digest_sort_compare_func(struct digest_list_entry *d1,
		struct digest_list_entry *d2)
deleted libpkg/private/thd_repo.h
@@ -1,67 +0,0 @@
-
/*-
-
 * Copyright (c) 2012 Julien Laffaye <jlaffaye@FreeBSD.org>
-
 * All rights reserved.
-
 * 
-
 * Redistribution and use in source and binary forms, with or without
-
 * modification, are permitted provided that the following conditions
-
 * are met:
-
 * 1. Redistributions of source code must retain the above copyright
-
 *    notice, this list of conditions and the following disclaimer
-
 *    in this position and unchanged.
-
 * 2. Redistributions in binary form must reproduce the above copyright
-
 *    notice, this list of conditions and the following disclaimer in the
-
 *    documentation and/or other materials provided with the distribution.
-
 * 
-
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
-
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
-
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 */
-

-
#ifndef _PKG_THD_REPO_H
-
#define _PKG_THD_REPO_H
-

-
#include <sys/types.h>
-
#include <pthread.h>
-

-
struct pkg_result {
-
	struct pkg *pkg;
-
	char path[MAXPATHLEN];
-
	char cksum[SHA256_DIGEST_LENGTH * 2 + 1];
-
	off_t size;
-
	int retcode; /* to pass errors */
-
	struct pkg_result *next, *prev;
-
};
-

-
struct thd_data {
-
	char *root_path;
-
	unsigned int max_results;
-

-
	/*
-
	 * `fts_m' protects `fts' and `stop'
-
	 */
-
	pthread_mutex_t fts_m;
-
	FTS *fts;
-
	bool stop;
-
	bool read_files;
-

-
	/*
-
	 * `results_m' protects `results', `thd_finished' and `num_results'
-
	 */
-
	pthread_mutex_t results_m;
-
	pthread_cond_t has_result;
-
	pthread_cond_t has_room;
-
	struct pkg_result *results;
-
	unsigned int num_results;
-
	int thd_finished;
-
};
-

-
void read_pkg_file(void *);
-

-
#endif
modified src/Makefile.am
@@ -43,8 +43,7 @@ pkg_CFLAGS= -I$(top_srcdir)/libpkg \
			-I$(top_srcdir)/external/expat/lib \
			-DGITHASH=\"$(GIT_HEAD)\"
pkg_static_SOURCES=
-
pkg_static_LDADD= @REPOS_LDADD_STATIC@ \	
-
			$(top_builddir)/libpkg/libpkg_static.la \
+
pkg_static_LDADD= $(top_builddir)/libpkg/libpkg_static.la \
			$(top_builddir)/external/libexpat_static.la \
			$(pkg_OBJECTS) \
			@LIBJAIL_LIB@ \
@@ -63,7 +62,7 @@ pkg_static_LDADD= @REPOS_LDADD_STATIC@ \
			-lcrypto \
			-lmd \
			-lm
-
pkg_static_LDFLAGS=	-all-static -pthread
+
pkg_static_LDFLAGS=	-all-static
sbin_PROGRAMS=		pkg pkg-static

dist_sysconf_DATA=	pkg.conf.sample