From 0fd559ce7967073270dc74b6f35f12e30b6c9057 Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 5 Jan 2015 20:24:45 +0200 Subject: [PATCH] Added a fallback for older glibc libraries. --- HISTORY | 1 + socket.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/HISTORY b/HISTORY index 560c950..0e130e4 100644 --- a/HISTORY +++ b/HISTORY @@ -94,3 +94,4 @@ VDR Plugin 'satip' Revision History - Updated the command-line help and README. - Fixed the server teardown. - Removed the unnecessary config directory definition. +- Added a fallback for older glibc libraries. diff --git a/socket.c b/socket.c index d6a9e50..358d506 100644 --- a/socket.c +++ b/socket.c @@ -136,6 +136,7 @@ int cSatipSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cSatipSocket::ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRecvSizeP, unsigned int elementCountP, unsigned int elementBufferSizeP) { debug16("%s (, , %d, %d)", __PRETTY_FUNCTION__, elementCountP, elementBufferSizeP); +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,12) // Error out if socket not initialized if (socketDescM <= 0) { error("%s Invalid socket", __PRETTY_FUNCTION__); @@ -159,6 +160,17 @@ int cSatipSocket::ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRec ERROR_IF_RET(count < 0 && errno != EAGAIN && errno != EWOULDBLOCK, "recvmmsg()", return -1); for (int i = 0; i < count; ++i) elementRecvSizeP[i] = mmsgh[i].msg_len; +#else + int count = 0; + while (count < (int)elementCountP) { + int len = Read(bufferAddrP + count * elementBufferSizeP, elementBufferSizeP); + if (len < 0) + return -1; + else if (len == 0) + break; + elementRecvSizeP[count++] = len; + } +#endif debug16("%s Received %d packets size[0]=%d", __PRETTY_FUNCTION__, count, elementRecvSizeP[0]); return count;