Add patch for 952193; fix to py3 packaging.

This commit is contained in:
Jason Tibbitts 2015-07-14 15:22:31 -05:00
parent ad88c22af2
commit 5536a8639f
2 changed files with 129 additions and 3 deletions

View File

@ -0,0 +1,118 @@
From 5cf2d9e32dffc902ca5a6f0220904f8dca8ec055 Mon Sep 17 00:00:00 2001
From: "Lee, Chun-Yi" <jlee@suse.com>
Date: Fri, 7 Sep 2012 04:37:33 +0800
Subject: [PATCH] avahi-core: reserve space for record data when size estimate
When we tested put a lot of airprint service files(have 45 to 60 flies), found there have cpu loadinghigh problem when start avahi-daemon with those service files.
After traced source code, there have problem in probe-sched.c::elapse_callback causes doesn't have any probe job set to DONE so the daemon unlimited send out DNS package.
The root cause is when compare with the free package space in packet_add_probe_query before attach job key, the free package space doesn't include any record data that will attached after all keys attached. This defect causes whole DNS package is filled by job key, but doesn't remain enough space for any rdata. Then, that means have no job set to DONE.
This patch add a new res_size member to AvahiDnsPacket, it used to sum the reserve size for record data the will attached after all keys attached. It can avoid keys consume whole size until p->size larger then p->max_size.
Signed-off-by: Lee, Chun-Yi <jlee at suse.com>
---
avahi-core/dns.c | 20 ++++++++++++++++++++
avahi-core/dns.h | 4 +++-
avahi-core/probe-sched.c | 10 ++++++++--
3 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/avahi-core/dns.c b/avahi-core/dns.c
index 2fcd91f..523afdc 100644
--- a/avahi-core/dns.c
+++ b/avahi-core/dns.c
@@ -55,6 +55,7 @@ AvahiDnsPacket* avahi_dns_packet_new(unsigned mtu) {
p->size = p->rindex = AVAHI_DNS_PACKET_HEADER_SIZE;
p->max_size = max_size;
+ p->res_size = 0;
p->name_table = NULL;
p->data = NULL;
@@ -833,6 +834,25 @@ size_t avahi_dns_packet_space(AvahiDnsPacket *p) {
return p->max_size - p->size;
}
+size_t avahi_dns_packet_reserve_size(AvahiDnsPacket *p, size_t res_size) {
+ assert(p);
+
+ assert(p->size + p->res_size <= p->max_size);
+
+ if ((p->size + p->res_size + res_size) <= p->max_size)
+ p->res_size += res_size;
+
+ return p->res_size;
+}
+
+size_t avahi_dns_packet_reserved_space(AvahiDnsPacket *p) {
+ assert(p);
+
+ assert(p->size + p->res_size <= p->max_size);
+
+ return p->max_size - p->size - p->res_size;
+}
+
int avahi_rdata_parse(AvahiRecord *record, const void* rdata, size_t size) {
int ret;
AvahiDnsPacket p;
diff --git a/avahi-core/dns.h b/avahi-core/dns.h
index 52e8d88..13b1ac2 100644
--- a/avahi-core/dns.h
+++ b/avahi-core/dns.h
@@ -30,7 +30,7 @@
#define AVAHI_DNS_PACKET_SIZE_MAX (AVAHI_DNS_PACKET_HEADER_SIZE + 256 + 2 + 2 + 4 + 2 + AVAHI_DNS_RDATA_MAX)
typedef struct AvahiDnsPacket {
- size_t size, rindex, max_size;
+ size_t size, rindex, max_size, res_size;
AvahiHashmap *name_table; /* for name compression */
uint8_t *data;
} AvahiDnsPacket;
@@ -78,6 +78,8 @@ int avahi_dns_packet_skip(AvahiDnsPacket *p, size_t length);
int avahi_dns_packet_is_empty(AvahiDnsPacket *p);
size_t avahi_dns_packet_space(AvahiDnsPacket *p);
+size_t avahi_dns_packet_reserve_size(AvahiDnsPacket *p, size_t res_size);
+size_t avahi_dns_packet_reserved_space(AvahiDnsPacket *p);
#define AVAHI_DNS_FIELD_ID 0
#define AVAHI_DNS_FIELD_FLAGS 1
diff --git a/avahi-core/probe-sched.c b/avahi-core/probe-sched.c
index 1e63411..63cb817 100644
--- a/avahi-core/probe-sched.c
+++ b/avahi-core/probe-sched.c
@@ -179,7 +179,7 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
avahi_record_get_estimate_size(pj->record);
/* Too large */
- if (size > avahi_dns_packet_space(p))
+ if (size > avahi_dns_packet_reserved_space(p))
return 0;
/* Create the probe query */
@@ -189,6 +189,9 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
b = !!avahi_dns_packet_append_key(p, k, 0);
assert(b);
+ /* reserve size for record data */
+ avahi_dns_packet_reserve_size(p, avahi_record_get_estimate_size(pj->record));
+
/* Mark this job for addition to the packet */
pj->chosen = 1;
@@ -202,9 +205,12 @@ static int packet_add_probe_query(AvahiProbeScheduler *s, AvahiDnsPacket *p, Ava
continue;
/* This job wouldn't fit in */
- if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_space(p))
+ if (avahi_record_get_estimate_size(pj->record) > avahi_dns_packet_reserved_space(p))
break;
+ /* reserve size for record data */
+ avahi_dns_packet_reserve_size(p, avahi_record_get_estimate_size(pj->record));
+
/* Mark this job for addition to the packet */
pj->chosen = 1;
}
--
1.7.10.4

View File

@ -18,7 +18,7 @@
Name: avahi
Version: 0.6.31
Release: 36%{?dist}
Release: 37%{?dist}
Summary: Local network service discovery
License: LGPLv2+
URL: http://avahi.org
@ -78,6 +78,8 @@ Patch3: 0001-netlink-check-that-the-origin-of-the-rtnetlink-messa.patc
Patch4: 0001-Python3-support.patch
Patch5: avahi-0.6.31-reserve-space-for-record-data-when-size-estimate.patch
%description
Avahi is a system which facilitates service discovery on
a local network -- this means that you can plug your laptop or
@ -347,6 +349,7 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%patch2 -p1 -b .disable-workstation-hinfo
%patch3 -p1 -b .netlink-userns
%patch4 -p1 -b .python3
%patch5 -p1 -b .reserve-size
rm docs/INSTALL
# patch1 requires autogen
@ -407,8 +410,9 @@ ln -s avahi-compat-libdns_sd/dns_sd.h %{buildroot}/%{_includedir}/
%endif
# Add python3 support
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/python3.4/site-packages/avahi/
cp -r $RPM_BUILD_ROOT%{_prefix}/lib/python2.?/site-packages/avahi/* $RPM_BUILD_ROOT%{_prefix}/lib/python3.4/site-packages/avahi/
mkdir -p %{buildroot}%{_prefix}/lib/python3.4/site-packages/avahi/
cp -r %{buildroot}%{_prefix}/lib/python2.?/site-packages/avahi/* %{buildroot}%{_prefix}/lib/python3.4/site-packages/avahi/
rm -fv %{buildroot}%{_prefix}/lib/python3.4/site-packages/avahi/*.py{c,o}
rm -fv %{buildroot}%{_sysconfdir}/rc.d/init.d/avahi-daemon
rm -fv %{buildroot}%{_sysconfdir}/rc.d/init.d/avahi-dnsconfd
@ -696,6 +700,10 @@ exit 0
%{_prefix}/lib/python3.?/site-packages/
%changelog
* Tue Jul 14 2015 Jason L Tibbitts III <tibbs@math.uh.edu> - 0.6.31-37
- Add old patch from SuSE to fix 100%% CPU bug (RHBZ 952193).
- Don't install py2.7 .py{o,c} files in py3.4 package.
* Sun Jun 21 2015 Bastien Nocera <bnocera@redhat.com> 0.6.31-36
- Split off Python bindings, add Python3 support