-
Notifications
You must be signed in to change notification settings - Fork 280
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
single-thread API: add usrsctp_get_timeout() #349
Labels
Comments
Merged
why was this closed? fixed by #591 |
What do you mean? This issue was closed because it was done here: #339 |
#339 adds static unsigned get_tick_count(void)
{
#ifdef _WIN32
return GetTickCount();
#else
struct timeval te;
gettimeofday(&te, NULL); // get current time
unsigned milliseconds = te.tv_sec*1000LL + te.tv_usec/1000; // calculate milliseconds
return milliseconds;
#endif
} but that looks very different from #591 int
usrsctp_get_timeout(void)
{
return sctp_get_next_tick();
}
int
sctp_get_next_tick(void)
{
int ret;
sctp_os_timer_t *c;
SCTP_TIMERQ_LOCK();
c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue));
if (c) {
uint32_t min_delta = UINT32_MAX;
while (c) {
uint32_t delta = c->c_time - ticks;
min_delta = (delta < min_delta) ? delta : min_delta;
c = TAILQ_NEXT(c, tqe);
}
ret = min_delta;
} else {
ret = -1;
}
SCTP_TIMERQ_UNLOCK();
return ret;
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #339 makes usrsctp work in single thread environments by forcing the application call
usrsctp_handle_timers()
periodically. While it's good enough (it does work), the optimized way of doing it would be by having an API like DTLSv1_get_timeout() and DTLSv1_handle_timeout in OpenSSL and BoringSSL.usrsctp already has
usrsctp_handle_timers()
so the only missing API would beusrsctp_get_timeout()
.This is, the application provides an input to the lib (via
usrsctp_socket()
,usrsctp_close()
,usrsctp_connect()
,usrsctp_conninput()
, etc) and retrieves from the lib (viausrsctp_get_timeout()
) the time that must elapse before the lib (usrsctp) would need to do something (like sending a retransmission, a chunk or whatever). And then the app would set its own timer with that expiration value and callusrsctp_handle_timers()
when it expires. This would be much more efficient that the current approach in which the app must callusrsctp_handle_timers()
every N ms just in case the lib has something to do at that time.As @tuexen said:
IMPORTANT: It should be very clear and well documented when the app should call
usrsctp_get_timeout()
, this is: the app should callusrsctp_get_timeout()
and prepare a new timer after calling which usrsctp functions and after which usrsctp events.The text was updated successfully, but these errors were encountered: