]> git.pld-linux.org Git - packages/distcc.git/blame - distcc-hostopt.patch
- rel 0.2; use distcc user instead of nobody
[packages/distcc.git] / distcc-hostopt.patch
CommitLineData
ce11ba31 1--- src/distcc.c.orig Mon May 5 07:25:00 2003
2+++ src/distcc.c Mon May 5 21:07:30 2003
3@@ -117,8 +117,14 @@
4 "Each host can be given in any of these forms:\n"
57ce76bb 5 "\n"
57ce76bb 6 " localhost run in place\n"
7-" HOST TCP connection, port %d\n"
8-" HOST:PORT TCP connection, specified port\n"
9+" HOST[:PORT][,OPT...] TCP connection (default port=%d)\n"
10+"\n"
11+"OPT Values:\n"
12+" slots=N Maximum of N simultaneous jobs allowed\n"
13+" N Abbreviation of the slots=N option\n"
14+"\n"
15+"Hostname examples:\n"
16+" foo foo:4242 foo,4 bar:4100,2 bar,slots=3\n"
ce11ba31 17 " @HOST SSH connection\n"
18 " USER$HOST SSH connection to specified host\n"
57ce76bb 19 "\n"
ce11ba31 20--- src/hosts.c.orig Mon May 5 06:59:53 2003
21+++ src/hosts.c Mon May 5 21:01:23 2003
22@@ -176,21 +176,43 @@
57ce76bb 23 }
24
ce11ba31 25
57ce76bb 26-static int dcc_parse_multiplier(const char **psrc, struct dcc_hostdef *hostdef)
27+static int dcc_parse_options(const char **psrc, struct dcc_hostdef *hostdef)
28 {
29- char *mul;
30- const char *token = *psrc;
31+ char *opt, *arg;
32+ const char *token;
33 int ret;
34
35- if ((*psrc)[0] == '/') {
36- (*psrc)++;
37- if ((ret = dcc_dup_part(psrc, &mul, "/: \t\n\f")) != 0)
38+ while ((*psrc)[0] == ',') {
39+ token = (*psrc)++;
40+ if ((ret = dcc_dup_part(psrc, &opt, ", \t\n\f")) != 0)
41 return ret;
42- if (!mul || atoi(mul) == 0) {
43- rs_log_error("bad multiplier \"%s\" in host specification", token);
44+ if (opt) {
45+ if ((arg = strchr(opt, '=')) != NULL)
46+ *arg++ = '\0';
47+ else if (isdigit(*opt)) {
48+ arg = opt;
49+ opt = NULL;
50+ }
51+ else
52+ arg = NULL;
53+ }
54+ else
55+ arg = NULL;
56+ if (!arg) {
57+ rs_log_error("malformed option in host specification: \"%s\"", token);
58+ return EXIT_BAD_HOSTSPEC;
59+ }
60+ if (!opt || strcmp(opt, "slots") == 0) {
61+ hostdef->n_slots = atoi(arg);
62+ if (hostdef->n_slots <= 0) {
63+ rs_log_error("invalid number of slots in host specification: \"%s\"", token);
64+ return EXIT_BAD_HOSTSPEC;
65+ }
66+ }
67+ else {
68+ rs_log_error("unknown option in host specification: \"%s\"", token);
69 return EXIT_BAD_HOSTSPEC;
70 }
71- hostdef->n_slots = atoi(mul);
72 }
73 return 0;
74 }
ce11ba31 75@@ -211,7 +233,7 @@
76
57ce76bb 77 token++;
78
79- if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
80+ if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
81 return ret;
82
83 if (!hostdef->hostname) {
ce11ba31 84@@ -220,15 +242,15 @@
57ce76bb 85 return EXIT_BAD_HOSTSPEC;
86 }
87
88- if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
89- return ret;
90-
91 if (token[0] == ':') {
92 token++;
93- if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, " \t\n\f")) != 0)
94+ if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, ", \t\n\f")) != 0)
95 return ret;
96 }
97-
98+
99+ if ((ret = dcc_parse_options(&token, hostdef)) != 0)
100+ return ret;
101+
102 hostdef->mode = DCC_MODE_SSH;
103 return 0;
104 }
ce11ba31 105@@ -241,7 +263,7 @@
57ce76bb 106 int ret;
107 const char *token = token_start;
108
109- if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
110+ if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
111 return ret;
112
113 if (!hostdef->hostname) {
ce11ba31 114@@ -250,14 +272,11 @@
57ce76bb 115 return EXIT_BAD_HOSTSPEC;
116 }
117
118- if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
119- return ret;
120-
121 hostdef->port = dcc_default_port;
122 if (token[0] == ':') {
123 token++;
124
125- if ((ret = dcc_dup_part(&token, &port_str, " \t\n\f")) != 0)
126+ if ((ret = dcc_dup_part(&token, &port_str, ", \t\n\f")) != 0)
127 return ret;
128
129 if (port_str) {
ce11ba31 130@@ -270,7 +289,10 @@
57ce76bb 131 free(port_str);
132 }
133 }
134-
135+
136+ if ((ret = dcc_parse_options(&token, hostdef)) != 0)
137+ return ret;
138+
139 hostdef->mode = DCC_MODE_TCP;
140 return 0;
141 }
ce11ba31 142@@ -279,13 +301,13 @@
57ce76bb 143 static int dcc_parse_localhost(struct dcc_hostdef *hostdef,
144 const char * token_start)
145 {
146- const char *token = token_start + strlen("localhost");
147+ const char *token = token_start + (sizeof "localhost") - 1;
148
149 hostdef->mode = DCC_MODE_LOCAL;
150 hostdef->hostname = strdup("localhost");
151 hostdef->n_slots = 1;
152
153- return dcc_parse_multiplier(&token, hostdef);
154+ return dcc_parse_options(&token, hostdef);
155 }
156
157
ce11ba31 158@@ -316,7 +338,7 @@
57ce76bb 159 * definition. We then duplicate the relevant subcomponents into
160 * the relevant fields. */
161 while (1) {
162- int token_len;
163+ unsigned int token_len;
164 const char *token_start;
165 int has_at;
166
ce11ba31 167@@ -347,8 +369,10 @@
168
57ce76bb 169 has_at = (memchr(token_start, '@', token_len) != NULL);
ce11ba31 170
57ce76bb 171- if (!strncmp(token_start, "localhost", token_len)
172- || !strncmp(token_start, "localhost/", strlen("localhost/"))) {
ce11ba31 173+ if (token_len >= (sizeof "localhost")-1
174+ && strncmp(token_start, "localhost", (sizeof "localhost")-1) == 0
175+ && (token_len == (sizeof "localhost")-1
176+ || token_start[(sizeof "localhost")-1] == ',')) {
57ce76bb 177 if ((ret = dcc_parse_localhost(curr, token_start)) != 0)
178 return ret;
179 } else if (has_at) {
12373ad3 180--- linuxdoc/distcc.sgml.orig Fri May 16 08:43:29 2003
181+++ linuxdoc/distcc.sgml Sat May 17 21:38:13 2003
182@@ -174,7 +174,7 @@
183 On the client, set the <tt>DISTCC_HOSTS</tt> environment
184 variable to indicate which volunteer machines to use.
185 For example:
186- <tscreen><verb>DISTCC_HOSTS='angry toey:4202 localhost'</verb></tscreen>
187+ <tscreen><verb>HOSTNAME[:PORT][,OPT...]</verb></tscreen>
188
189 <item>
190 Set the <tt>CC</tt> variable or edit Makefiles to prefix
191@@ -182,6 +182,13 @@
192 <tscreen><verb>distcc gcc -o hello.o -c hello.c</verb></tscreen>
193 </enum>
194 </p>
195+
196+ <p>
197+ You can specify one or more host-specific options at the end of the
198+ host-spec by appending each one after a comma. The current option
199+ is slots=N (abbreviated as just N, if desired).
200+ The "slots" option specifies the maximum number of jobs that the
201+ associated host should be given simultaneously (e.g. "localhost,2").
202 </sect>
203
204
This page took 0.046049 seconds and 4 git commands to generate.