@@ -117,66 +117,6 @@ static std::string getExecutablePath() {
117117#endif
118118 return std::string (exePath);
119119}
120-
121- /*
122- * return true if the given limit is smaller, than the sytem limit or if it has been increased.
123- * return false if the limit could not be requested or set.
124- */
125- static
126- bool set_maximal_file_limit (size_t new_max_limit){
127- // check if the number of barcodes (corresponds to the number of files) is higher than the maximum limit of open file handles, allowed by the system.
128- #ifndef _WIN32
129- rlimit old_limit, new_limit;
130- int received_limit = getrlimit (RLIMIT_NOFILE, &old_limit);
131- if (received_limit == 0 )
132- {
133- printf (" Open files limit soft %ld, hard %ld, required %zu\n " , old_limit.rlim_cur , old_limit.rlim_max , new_max_limit);
134- if ((old_limit.rlim_cur < new_max_limit) || (old_limit.rlim_max < new_max_limit)){
135- size_t real_new_limit = min (new_max_limit,(size_t )RLIM_INFINITY);
136- if (old_limit.rlim_cur < new_max_limit)
137- new_limit.rlim_cur = real_new_limit;
138- if (old_limit.rlim_max < new_max_limit)
139- new_limit.rlim_max = real_new_limit;
140- int set_limit = setrlimit (RLIMIT_NOFILE, &new_limit);
141- if (set_limit == 0 ){
142- fprintf (stdout, " Maximum open file limit has been increased to %zu\n " , real_new_limit);
143- return true ;
144- }
145- else {
146- fprintf (stderr, " Error: the maximum open file limit for the filesystem could not be set!\n " );
147- return false ;
148- }
149- }
150- else {
151- // increasing was not necessary
152- return true ;
153- }
154- }
155- else {
156- fprintf (stderr, " Error: the maximum open file limit for the filesystem could not be retrieved!\n " );
157- return false ;
158- }
159- #else
160- int current_limit = _getmaxstdio ();
161- if (current_limit < new_max_limit){
162- printf (" Open files limit %d, new %zu\n " , current_limit, new_max_limit);
163- int set_limit = _setmaxstdio (new_max_limit);
164- if (!set_limit){
165- fprintf (stderr, " Error: the maximum file limit for the filesystem could not be set!\n " );
166- return false ;
167- }
168- fprintf (stdout, " Maximum open file limit has been increased to %zu\n " , new_max_limit);
169- return true ;
170- }
171- else {
172- // increasing was not necessary
173- return true ;
174- }
175-
176- #endif
177- return false ;
178- }
179120};
180121
181-
182122#endif /* SRC_HELPER_H_ */
0 commit comments