liblog: add __android_log_config_*_close()
Add __android_log_config_read_close() and __android_log_config_write_close(). Fortify the list macros to detect for list corruption, looking for entries pointing to themselves, deleted entries in list. Test: gTest liblog-unit-tests Bug: 27405083 Change-Id: I33e8a0cae7e202f1989ddd7c2a96752b44c8e746
This commit is contained in:
parent
cf983bcbae
commit
96432fc665
4 changed files with 58 additions and 14 deletions
|
@ -60,3 +60,15 @@ LIBLOG_HIDDEN void __android_log_config_read() {
|
|||
__android_log_add_transport(&__android_log_persist_read, &pmsgLoggerRead);
|
||||
#endif
|
||||
}
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_read_close() {
|
||||
struct android_log_transport_read *transport;
|
||||
struct listnode *n;
|
||||
|
||||
read_transport_for_each_safe(transport, n, &__android_log_transport_read) {
|
||||
list_remove(&transport->node);
|
||||
}
|
||||
read_transport_for_each_safe(transport, n, &__android_log_persist_read) {
|
||||
list_remove(&transport->node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,22 +28,31 @@ extern LIBLOG_HIDDEN struct listnode __android_log_persist_read;
|
|||
|
||||
#define read_transport_for_each(transp, transports) \
|
||||
for ((transp) = node_to_item((transports)->next, \
|
||||
struct android_log_transport_read, node); \
|
||||
((transp) != node_to_item(transports, \
|
||||
struct android_log_transport_read, node)); \
|
||||
struct android_log_transport_read, node); \
|
||||
((transp) != node_to_item((transports), \
|
||||
struct android_log_transport_read, \
|
||||
node)) && \
|
||||
((transp) != node_to_item((transp)->node.next, \
|
||||
struct android_log_transport_read, \
|
||||
node)); \
|
||||
(transp) = node_to_item((transp)->node.next, \
|
||||
struct android_log_transport_read, node)) \
|
||||
struct android_log_transport_read, node))
|
||||
|
||||
#define read_transport_for_each_safe(transp, n, transports) \
|
||||
for ((transp) = node_to_item((transports)->next, \
|
||||
struct android_log_transport_read, node), \
|
||||
struct android_log_transport_read, node), \
|
||||
(n) = (transp)->node.next; \
|
||||
((transp) != node_to_item(transports, \
|
||||
struct android_log_transport_read, node)); \
|
||||
(transp) = node_to_item(n, struct android_log_transport_read, node), \
|
||||
((transp) != node_to_item((transports), \
|
||||
struct android_log_transport_read, \
|
||||
node)) && \
|
||||
((transp) != node_to_item((n), struct android_log_transport_read, \
|
||||
node)); \
|
||||
(transp) = node_to_item((n), struct android_log_transport_read, \
|
||||
node), \
|
||||
(n) = (transp)->node.next)
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_read();
|
||||
LIBLOG_HIDDEN void __android_log_config_read_close();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -64,3 +64,17 @@ LIBLOG_HIDDEN void __android_log_config_write() {
|
|||
__android_log_add_transport(&__android_log_transport_write, &fakeLoggerWrite);
|
||||
#endif
|
||||
}
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_write_close() {
|
||||
struct android_log_transport_write *transport;
|
||||
struct listnode *n;
|
||||
|
||||
write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
|
||||
transport->logMask = 0;
|
||||
list_remove(&transport->node);
|
||||
}
|
||||
write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
|
||||
transport->logMask = 0;
|
||||
list_remove(&transport->node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,21 +29,30 @@ extern LIBLOG_HIDDEN struct listnode __android_log_persist_write;
|
|||
#define write_transport_for_each(transp, transports) \
|
||||
for ((transp) = node_to_item((transports)->next, \
|
||||
struct android_log_transport_write, node); \
|
||||
((transp) != node_to_item(transports, \
|
||||
struct android_log_transport_write, node)); \
|
||||
((transp) != node_to_item((transports), \
|
||||
struct android_log_transport_write, \
|
||||
node)) && \
|
||||
((transp) != node_to_item((transp)->node.next, \
|
||||
struct android_log_transport_write, \
|
||||
node)); \
|
||||
(transp) = node_to_item((transp)->node.next, \
|
||||
struct android_log_transport_write, node)) \
|
||||
struct android_log_transport_write, node))
|
||||
|
||||
#define write_transport_for_each_safe(transp, n, transports) \
|
||||
for ((transp) = node_to_item((transports)->next, \
|
||||
struct android_log_transport_write, node), \
|
||||
(n) = (transp)->node.next; \
|
||||
((transp) != node_to_item(transports, \
|
||||
struct android_log_transport_write, node)); \
|
||||
(transp) = node_to_item(n, struct android_log_transport_write, node), \
|
||||
((transp) != node_to_item((transports), \
|
||||
struct android_log_transport_write, \
|
||||
node)) && \
|
||||
((transp) != node_to_item((n), struct android_log_transport_write, \
|
||||
node)); \
|
||||
(transp) = node_to_item((n), struct android_log_transport_write, \
|
||||
node), \
|
||||
(n) = (transp)->node.next)
|
||||
|
||||
LIBLOG_HIDDEN void __android_log_config_write();
|
||||
LIBLOG_HIDDEN void __android_log_config_write_close();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue