Comments (9)
When I am off work, I will need help with that. I have little experience with GIT and no experience with GitHub.
from task-spooler.
Hey @tomaszklim. Thanks for the suggesstion. Do you want to send a PR?
from task-spooler.
Changed server.c to dynamically allocate memory for client_cs from getrlimit, which removes the hardcoded, arbitrary limit of 1000. [issue #52]
--- task-spooler-main/server.c 2023-11-26 21:13:44.622381307 -0800
+++ task-spooler/server.c 2023-11-26 20:31:51.485209017 -0800
@@ -29,10 +29,6 @@
#include "main.h"
-enum {
- MAXCONN = 1000
-};
-
enum Break {
BREAK,
NOBREAK,
@@ -63,7 +59,7 @@
};
/* Globals */
-static struct Client_conn client_cs[MAXCONN];
+static struct Client_conn *client_cs;
static int nconnections;
static char *path;
static int max_descriptors;
@@ -131,12 +127,16 @@
static int get_max_descriptors() {
const int MARGIN = 5; /* stdin, stderr, listen socket, and whatever */
- int max;
+ int max = 1000; /* initial value used only if getrlimit fails to return a value */
struct rlimit rlim;
int res;
const char *str;
- max = MAXCONN;
+ res = getrlimit(RLIMIT_NOFILE, &rlim);
+ if (res != 0)
+ warning("getrlimit for open files");
+ else
+ max = rlim.rlim_cur - MARGIN;
str = getenv("TS_MAXCONN");
if (str != NULL) {
@@ -149,17 +149,6 @@
if (max > FD_SETSIZE)
max = FD_SETSIZE - MARGIN;
- /* I'd like to use OPEN_MAX or NR_OPEN, but I don't know if any
- * of them is POSIX compliant */
-
- res = getrlimit(RLIMIT_NOFILE, &rlim);
- if (res != 0)
- warning("getrlimit for open files");
- else {
- if (max > rlim.rlim_cur)
- max = rlim.rlim_cur - MARGIN;
- }
-
if (max < 1)
error("Too few opened descriptors available");
@@ -174,6 +163,9 @@
process_type = SERVER;
max_descriptors = get_max_descriptors();
+
+ /* allocate dynamic memory for client_cs, thus removing any arbitrary limit */
+ client_cs = malloc(max_descriptors * sizeof(struct Client_conn));
/* Arbitrary limit, that will block the enqueuing, but should allow space
* for usual ts queries */
@@ -316,6 +308,7 @@
/* This comes from the parent, in the fork after server_main.
* This is the last use of path in this process.*/
free(path);
+ free(client_cs);
free(logdir);
#ifndef CPU
cleanupGpu();
from task-spooler.
Hey @technojoe. Great job! Can you send a PR for this? Thanks!
from task-spooler.
@technojoe let me know if you need any help
from task-spooler.
from task-spooler.
@justanhduc Anyone going to pull this in?
from task-spooler.
hey @technojoe. I'm a bit occupied these days. I will check it asap. Thanks a lot for your contrib!
from task-spooler.
from task-spooler.
Related Issues (20)
- Advice on how to cancel (kill or remove) task HOT 5
- Prompt to uninstall the apt installation of tsp before running ts in README HOT 1
- install breaks without CUDA HOT 1
- Bug: cannot add a very long command to queue HOT 14
- Structured output HOT 2
- Please edit the README HOT 2
- make cpu giving error: implicitly declaring library function 'snprintf' with type 'int HOT 2
- Evaluate $(...) in commands at run not at enqueue HOT 2
- Separate logging and queueing? HOT 3
- Using `-n` `-f` flags: pass through SIGINT (and other signals?) HOT 1
- ts -F stochastically crashes the server HOT 3
- Contributors HOT 7
- GUI addon link point to 404 HOT 3
- asynchronous launch HOT 6
- Timeout HOT 3
- json format for listing jobs HOT 1
- Unable to redirect output from command line HOT 2
- Enhancement request: support for priorities HOT 2
- Enhancement request: ability to postpone jobs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from task-spooler.