From 4600a2a070432540e1b92f66613225a3a0d0f4a8 Mon Sep 17 00:00:00 2001 From: nafets227 Date: Sat, 29 Nov 2014 19:16:59 +0100 Subject: [PATCH] Performance improvement by avoiding locks in cSatipTuner::ProcessApplicationData(). Don't use malloc, but put variable on stack (=local char array). This avoids a possible lock with other threads, because malloc uses global storage and needs a lock then. Tests eliminated the long lasting processing of RTCP packaged in poller Thread. --- tuner.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tuner.c b/tuner.c index 8471720..621fd86 100644 --- a/tuner.c +++ b/tuner.c @@ -262,7 +262,8 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) // DVB-C2: // ver=1.2;tuner=,,,,,,,,,,,,;pids=,..., if (lengthP > 0) { - char *s = strndup((char *)bufferP, lengthP); + char s[lengthP]; + memcpy(s, (char *)bufferP, lengthP); //debug("cSatipTuner::%s(%s) [device %d]", __FUNCTION__, s, deviceIdM); char *c = strstr(s, ";tuner="); if (c) { @@ -297,7 +298,6 @@ void cSatipTuner::ProcessApplicationData(u_char *bufferP, int lengthP) // Scale value to 0-100 signalQualityM = (hasLockM && (value >= 0)) ? (value * 100 / 15) : 0; } - free(s); } reConnectM.Set(eConnectTimeoutMs); }