summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-01-09 08:05:05 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-01-09 08:05:05 (EST)
commit6b3819c6d9b86832b41f6caa865596f6fb204c8e (patch)
treed2a33a8fe8128f821ef7adb0d2d787f1895efc52
parent7bf0f50d8bc7245b0e89bd5b3c84d84d1c3629c0 (diff)
Making the status_file singleton, every package is using the same file,
and it should be handled only once. Let status_file works (make the dest->status_file obsolete) git-svn-id: http://opkg.googlecode.com/svn/trunk@196 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r--libopkg/opkg_conf.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index ac785c8..45e3d2b 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -647,22 +647,21 @@ static int opkg_conf_set_option(const opkg_option_t *options,
int opkg_conf_write_status_files(opkg_conf_t *conf)
{
- pkg_dest_list_elt_t *iter;
pkg_dest_t *dest;
pkg_vec_t *all;
pkg_t *pkg;
register int i;
int err;
+ FILE * status_file=NULL;
if (conf->noaction)
return 0;
- for (iter = void_list_first(&conf->pkg_dest_list); iter; iter = void_list_next(&conf->pkg_dest_list, iter)) {
- dest = (pkg_dest_t *)iter->data;
- dest->status_file = fopen(dest->status_file_tmp_name, "w");
- if (dest->status_file == NULL) {
- fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
- __FUNCTION__, dest->status_file_name, strerror(errno));
- }
+
+ dest = (pkg_dest_t *)void_list_first(&conf->pkg_dest_list)->data;
+ status_file = fopen(dest->status_file_tmp_name, "w");
+ if (status_file == NULL) {
+ fprintf(stderr, "%s: Can't open status file: %s for writing: %s\n",
+ __FUNCTION__, dest->status_file_tmp_name, strerror(errno));
}
all = pkg_vec_alloc();
@@ -686,29 +685,25 @@ int opkg_conf_write_status_files(opkg_conf_t *conf)
__FUNCTION__, pkg->name);
continue;
}
- if (pkg->dest->status_file) {
- pkg_print_status(pkg, pkg->dest->status_file);
+ if (status_file) {
+ pkg_print_status(pkg, status_file);
}
}
pkg_vec_free(all);
- for (iter = void_list_first(&conf->pkg_dest_list); iter; iter = void_list_next(&conf->pkg_dest_list, iter)) {
- dest = (pkg_dest_t *)iter->data;
- if (dest->status_file) {
- err = ferror(dest->status_file);
- fclose(dest->status_file);
- dest->status_file = NULL;
- if (!err) {
- file_move(dest->status_file_tmp_name, dest->status_file_name);
- } else {
- fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
- "retaining old %s\n", __FUNCTION__,
- dest->status_file_tmp_name, dest->status_file_name);
- }
- }
+ if (status_file) {
+ err = ferror(status_file);
+ fclose(status_file);
+ if (!err) {
+ file_move(dest->status_file_tmp_name, dest->status_file_name);
+ } else {
+ fprintf(stderr, "%s: ERROR: An error has occurred writing %s, "
+ "retaining old %s\n", __FUNCTION__,
+ dest->status_file_tmp_name, dest->status_file_name);
+ }
+ status_file = NULL;
}
-
return 0;
}