uniba-swt / swtbahn-cli

A client-server command line interface for the SWTbahn.
GNU General Public License v3.0
7 stars 3 forks source link

drive_route function may run indefinitely if train is lost temporarily during driving #68

Closed BLuedtke closed 1 year ago

BLuedtke commented 2 years ago

This issue concerns the drive_route function as present starting on line 107 in file server/src/handler_driver.c.

The loop commented with "// Wait until the next segment is entered" (Line 152) can only ever be exited if the server is being shut down or if the train enters one particular 'next' segment (path_item). When driving in practice, the train is sometimes lost or recognized as a different train for a few seconds. If the train passes over the expected next segment during this time, the loop will never be exited (until shutdown).

Outline for possible solution: Check for entering of any segments still "left" on the route. If a segment further ahead is entered, skip looking for the current segment. Note: This must be implemented with routes in mind that can enter the same segment twice along a route.

eyip002 commented 2 years ago

Pull changes from the master branch

eyip002 commented 2 years ago

Can manually terminate route driving by releasing the route: drive_route_params_valid () becomes false.

https://github.com/uniba-swt/swtbahn-cli/blob/d414eaae3172c275289069b07c10d77eb06bc93a/server/src/handler_driver.c#L135

https://github.com/uniba-swt/swtbahn-cli/blob/d414eaae3172c275289069b07c10d77eb06bc93a/server/src/handler_driver.c#L189

BLuedtke commented 1 year ago

New fix implemented and tested, pull request will be up soon.