server session CHANGE make ps poll transport-specific
This means it must be active polling, but should
be always reliable.
Fixes cesnet/netopeer2#14
diff --git a/src/session.c b/src/session.c
index 2ceb80e..afc89f5 100644
--- a/src/session.c
+++ b/src/session.c
@@ -64,6 +64,30 @@
#endif
}
+/* ts1 < ts2, returns milliseconds */
+uint32_t
+nc_difftimespec(struct timespec *ts1, struct timespec *ts2)
+{
+ uint64_t nsec_diff = 0;
+
+ if (ts1->tv_nsec > ts2->tv_nsec) {
+ ts2->tv_nsec += 1000000000L;
+ --ts2->tv_sec;
+ }
+
+ if (ts1->tv_sec <= ts2->tv_sec) {
+ nsec_diff += (ts2->tv_sec - ts1->tv_sec) * 1000000000L;
+ } else {
+ ERRINT;
+ }
+
+ if (ts1->tv_nsec < ts2->tv_nsec) {
+ nsec_diff += ts2->tv_nsec - ts1->tv_nsec;
+ }
+
+ return (nsec_diff ? nsec_diff / 1000000L : 0);
+}
+
#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
int
pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abstime)