Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change system time backward will let st-srs behavior abnormal #3978

Open
suzp1984 opened this issue Mar 6, 2024 · 1 comment · May be fixed by #3979
Open

change system time backward will let st-srs behavior abnormal #3978

suzp1984 opened this issue Mar 6, 2024 · 1 comment · May be fixed by #3979
Assignees
Labels
EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.

Comments

@suzp1984
Copy link
Contributor

suzp1984 commented Mar 6, 2024

Root Cause

#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)

the default implementation of get timestamp of microseconds is depends on system time.

man gettimeofday

the st-srs has api that let us to config our own get timestamp function, but srs didn't config it.

/*****************************************
* Time functions
*/
st_utime_t st_utime(void)
{
if (_st_utime == NULL) {
#ifdef MD_GET_UTIME
MD_GET_UTIME();
#else
#error Unknown OS
#endif
}
return (*_st_utime)();
}
int st_set_utime_function(st_utime_t (*func)(void))
{
if (_st_active_count) {
errno = EINVAL;
return -1;
}
_st_utime = func;
return 0;
}

Solutions

refactor MD_GET_UTIME or Config a time function based on more robust solutions, e.g. system uptime, the timestamp since the system boot.

Version
All version

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'trunk/3rdparty/st-srs/tools/helloword/'
  2. run make
  3. run ./helloword
  4. change system time backward, e.g. change system time to one year before;
  5. check the Hello print will stuck.

Expected behavior
Change the system time should not impact the st-srs behavior.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Mar 6, 2024
@winlinvip
Copy link
Member

Nice work! Welcome to patch it.

@winlinvip winlinvip self-assigned this Mar 6, 2024
@winlinvip winlinvip added the Enhancement Improvement or enhancement. label Mar 6, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 7, 2024
@suzp1984 suzp1984 linked a pull request Mar 7, 2024 that will close this issue
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 7, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 9, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 9, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 18, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 18, 2024
suzp1984 added a commit to suzp1984/srs that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English. Enhancement Improvement or enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants