xrdp icon indicating copy to clipboard operation
xrdp copied to clipboard

Chansrv timer queue needs some attention

Open matt335672 opened this issue 1 year ago • 0 comments

xrdp version

devel

Problem description

Chansrv has a timer queue in chansrv/chansrv.c.

Events are added to the queue with add_timeout(). The caller specifies a time msoffset milli-seconds in the future and a callback function which is called when this time is reached.

There are a couple of problems with this code:-

  1. The milli-second time value is stored in a 32-bit unsigned int:- https://github.com/neutrinolabs/xrdp/blob/db70ce8b8d53f9206777d2ba5560c5ab83287599/sesman/chansrv/chansrv.c#L109-L115 This value wraps round every 49.7 days. Because of the way time comparisons are done, a wraparound of the value will cause timer events to stop firing.
  2. The timer queue is unordered. This means the whole timer queue has to be scanned every time the next timeout has to be calculated. Storing the timer queue in time-order would mean just the earliest event could be considered.

At present the timer queue is only called from the RAIL code so addressing this is a relatively low priority.

matt335672 avatar Jan 05 '24 12:01 matt335672