4 ms·
Checked the rust version, it has a toctou error right at the start, which likely would not happen in a non-cgi system because you’d do your db setup on load and
by masklinn 1y ago
Checked the rust version, it has a toctou error right at the start, which likely would not happen in a non-cgi system because you’d do your db setup on load and only then would accept requests. I assume the others are similar.
This neatly demonstrates one of the issues with CGI: they add synchronisation issues while removing synchronisation tooling.
- simonw 1y agoHad to look that up: Time-Of-Check-to-Time-Of-Use Here's that code: let new = !Path::new(DB_PATH).exists(); let conn = Connection::open(DB_PATH).expect("open db"); // ... if new { conn.execute_batch( r#" CREATE TABLE guestbook( So the bug here would occur only the very first time the script is executed, IF two processes run it at the same time such that one of them creates the file while the other one assumes the file did not exist yet and then tries to create the tables. That's pretty unlikely. In this case the losing script would return a 500 error to that single user when the CREATE TABLE fails. Honestly if this was my code I wouldn't even bother fixing that. (If I did fix it I'd switch to "CREATE TABLE IF NOT EXISTS...") ... but yeah, it's a good illustration of the point you're making about CGI introducing synchronization errors that wouldn't exist in app servers.
- kragen 1y agoThat sounds correct to me, but I think I would apply your suggested fix.
- deleted 1y ago[deleted]