mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 09:15:01 +01:00
fix: the simulator opens more than 512 files at once, and a shader it can't open says why
With "physicslog yes" every driver keeps its .dat open, and a large scenery (Tomaszewo: some 500 vehicles, cars of the roads included) took all 512 streams the MSVC runtime gives: the next fopen failed and the simulator stopped at "cannot read shader: shaders/map.vert" on opening the map. The limit is raised to 8192 at the start (the soft limit of open files up to the hard one on Linux), and a shader file that doesn't open is told as such, with the system's reason, rather than as one that can't be read.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#include <system_error>
|
||||
#include "shader.h"
|
||||
#include "glsl_common.h"
|
||||
#include "utilities/Logs.h"
|
||||
@@ -58,6 +60,12 @@ std::string gl::shader::read_file(const std::string &filename) const
|
||||
std::ifstream f;
|
||||
|
||||
f.open(filename);
|
||||
if (false == f.is_open())
|
||||
{
|
||||
// with the reason the system gives: a file which is there but can't be opened (too many files open) looks
|
||||
// the same as a missing one otherwise
|
||||
throw shader_exception("cannot open shader: " + filename + " (" + std::generic_category().message(errno) + ")");
|
||||
}
|
||||
stream << f.rdbuf();
|
||||
f.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user