Opened 2 years ago

Closed 2 years ago

#13392 closed Patch - Bug Fix (fixed)

Incorrect time conversion in dvbchannel.cpp

Reported by: Klaas de Waal Owned by: Klaas de Waal <kdewaal@…>
Priority: trivial Milestone: 30.1
Component: MythTV - DVB Version: Master Head
Severity: low Keywords: DVB timeout
Cc: Stuart Auchterlonie Ticket locked: no


Function wait_for_backend in dvbchannel.cpp has a time value in milliseconds in the second parameter. This value is converted from integer to struct timeval.

A struct timeval consists of a number of seconds plus a number of microseconds, as defined in /usr/include/bits/types/struct_timeval.h of Fedora 29:

#ifndef __timeval_defined
#define __timeval_defined 1

#include <bits/types.h>

/* A time value that is accurate to the nearest
   microsecond but also has a range of years.  */
struct timeval
  __time_t tv_sec;              /* Seconds.  */
  __suseconds_t tv_usec;        /* Microseconds.  */

The code in wait_for_backed does compute the number of microseconds but the number of seconds is set to zero. This is only correct if the value of parameter timeout_ms is less than 1000.
The attached patch does also compute the number of seconds.

Note that the existing code does not yet give any problems; the function wait_for_backend is called only from one place with a value of 50 milliseconds.

Attachments (1)

20190128-timeout-conversion.patch (641 bytes) - added by Klaas de Waal 2 years ago.

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by Klaas de Waal

comment:1 Changed 2 years ago by Klaas de Waal

This patch is separated out from ticket #13386 as requested.

comment:2 Changed 2 years ago by Stuart Auchterlonie

Milestone: needs_triage30.1

comment:3 Changed 2 years ago by Klaas de Waal <kdewaal@…>

Owner: set to Klaas de Waal <kdewaal@…>
Resolution: fixed
Status: newclosed

In c6a7cf1878/mythtv:

Change the time value conversion in function wait_for_backend.
The time is converted from milliseconds to a struct timeval in seconds and microseconds.
However, only the microseconds are computed and the number of seconds is set to zero.
This is only correct for time values up to 999 milliseconds.
The modified time computation also computes the number of seconds.

Fixes #13392

Signed-off-by: Klaas de Waal <kdewaal@…>

Note: See TracTickets for help on using tickets.