The following commit has been merged in the master branch:
commit a4298e6ff245505a5a963a08fe2d40ecad9c595e
Author: Guillem Jover <[email protected]>
Date: Tue Sep 6 05:59:13 2011 +0200
libdpkg: Refactor trig_awaited_pend_head processing into new functions
This will allow accessing trig_awaited_pend_head from a different
module, w/o needing to pull in triglib.
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 121fb90..dffc708 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -4,6 +4,7 @@
*
* Copyright © 2007 Canonical Ltd
* Written by Ian Jackson <[email protected]>
+ * Copyright © 2008-2011 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -203,6 +204,23 @@ trig_awaited_pend_enqueue(struct pkginfo *pend)
pkg_list_prepend(&trig_awaited_pend_head, pend);
}
+void
+trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func)
+{
+ struct pkg_list *tp;
+
+ for (tp = trig_awaited_pend_head; tp; tp = tp->next)
+ if (!tp->pkg->trigpend_head)
+ func(tp->pkg);
+}
+
+void
+trig_awaited_pend_free(void)
+{
+ pkg_list_free(trig_awaited_pend_head);
+ trig_awaited_pend_head = NULL;
+}
+
/*
* Fix up packages in state triggers-awaited w/o the corresponding package
* with pending triggers. This can happen when dpkg was interrupted
@@ -215,17 +233,11 @@ trig_awaited_pend_enqueue(struct pkginfo *pend)
void
trig_fixup_awaiters(enum modstatdb_rw cstatus)
{
- struct pkg_list *tp;
-
if (cstatus < msdbrw_write)
return;
- for (tp = trig_awaited_pend_head; tp; tp = tp->next)
- if (!tp->pkg->trigpend_head)
- trig_clear_awaiters(tp->pkg);
-
- pkg_list_free(trig_awaited_pend_head);
- trig_awaited_pend_head = NULL;
+ trig_awaited_pend_foreach(trig_clear_awaiters);
+ trig_awaited_pend_free();
}
/*---------- Generalized handling of trigger kinds. ----------*/
diff --git a/lib/dpkg/triglib.h b/lib/dpkg/triglib.h
index 96e52b5..b870953 100644
--- a/lib/dpkg/triglib.h
+++ b/lib/dpkg/triglib.h
@@ -83,7 +83,12 @@ bool trig_note_pend(struct pkginfo *pend, const char *trig
/*not copied!*/);
bool trig_note_aw(struct pkginfo *pend, struct pkginfo *aw);
void trig_clear_awaiters(struct pkginfo *notpend);
+typedef void trig_awaited_pend_foreach_func(struct pkginfo *pkg);
+
void trig_awaited_pend_enqueue(struct pkginfo *pend);
+void trig_awaited_pend_foreach(trig_awaited_pend_foreach_func *func);
+void trig_awaited_pend_free(void);
+
void trig_fixup_awaiters(enum modstatdb_rw cstatus);
void trig_file_interests_ensure(void);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]