Unverified Commit abc1e4e3 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

work: avoid race conditions with frontend when calling checkout

parent f79e34fb
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -553,6 +553,8 @@ sub startup {
			my ( $self, %opt ) = @_;

			my $station = $opt{station};
			my $dep_eva = $opt{dep_eva};
			my $arr_eva = $opt{arr_eva};
			my $force   = $opt{force};
			my $uid     = $opt{uid};
			my $db      = $opt{db} // $self->pg->db;
@@ -576,6 +578,12 @@ sub startup {
			if ( $status->{errstr} and not $force ) {
				return ( 1, $status->{errstr} );
			}
			if ( $dep_eva and $dep_eva != $user->{dep_eva} ) {
				return ( 0, 'race condition' );
			}
			if ( $arr_eva and $arr_eva != $user->{arr_eva} ) {
				return ( 0, 'race condition' );
			}

			my $now     = DateTime->now( time_zone => 'Europe/Berlin' );
			my $journey = $self->in_transit->get(
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ sub run {
						$self->app->checkout(
							station => $arr,
							force   => 1,
							dep_eva => $dep,
							arr_eva => $arr,
							uid     => $uid
						);
					}
@@ -156,6 +158,8 @@ sub run {
					$self->app->checkout(
						station => $arr,
						force   => 0,
						dep_eva => $dep,
						arr_eva => $arr,
						uid     => $uid
					);
				}
@@ -167,6 +171,8 @@ sub run {
				my ( undef, $error ) = $self->app->checkout(
					station => $arr,
					force   => 1,
					dep_eva => $dep,
					arr_eva => $arr,
					uid     => $uid
				);
				if ($error) {