]> git.pld-linux.org Git - packages/distcc.git/blob - distcc-hostopt.patch
You can specify one or more host-specific options at the end of the
[packages/distcc.git] / distcc-hostopt.patch
1 Index: linuxdoc/distcc.sgml
2 --- linuxdoc/distcc.sgml        28 Mar 2003 06:33:09 -0000      1.103
3 +++ linuxdoc/distcc.sgml        2 Apr 2003 02:42:26 -0000
4 @@ -597,17 +597,19 @@
5           volunteer machines are available to run jobs.  This is a
6           space-separated list of host specifications, each of which
7           has the syntax:
8 -<tscreen><verb>HOSTNAME[/MAX_JOBS][:PORT]</verb></tscreen>
9 -
10 -       <p>
11 -         You can specify the maximum number of jobs that the host
12 -         should receive by affixing a number after a slash (e.g.
13 -         "localhost/2").
14 +<tscreen><verb>HOSTNAME[:PORT][,OPT...]</verb></tscreen>
15  
16         <p>
17           A numeric TCP port may optionally be specified after a
18           colon.  If no port is specified, it uses the default, which
19           is currently 3632.
20 +
21 +       <p>
22 +         You can specify one or more host-specific options at the end of the
23 +         host-spec by appending each one after a comma.  The current option
24 +         is slots=N (abbreviated as just N, if desired).
25 +         The "slots" option specifies the maximum number of jobs that the
26 +         associated host should be given simultaneously (e.g. "localhost,2").
27  
28         <p>
29           If only one invocation of distcc runs at a time, it will
30 Index: src/distcc.c
31 --- src/distcc.c        31 Mar 2003 08:17:26 -0000      1.166
32 +++ src/distcc.c        2 Apr 2003 02:42:26 -0000
33 @@ -114,8 +114,14 @@
34  "\n"
35  "Host specifications:\n"
36  "   localhost                  run in place\n"
37 -"   HOST                       TCP connection, port %d\n"
38 -"   HOST:PORT                  TCP connection, specified port\n"
39 +"   HOST[:PORT][,OPT...]       TCP connection (default port=%d)\n"
40 +"\n"
41 +"OPT Values:\n"
42 +"   slots=N                    Maximum of N simultaneous jobs allowed\n"
43 +"   N                          Abbreviation of the slots=N option\n"
44 +"\n"
45 +"Hostname examples:\n"
46 +"   foo   foo:4242   foo,4   bar:4100,2   bar,slots=3\n"
47  "\n"
48  "distcc distributes compilation jobs across volunteer machines running\n"
49  "distccd.  Jobs that cannot be distributed, such as linking or \n"
50 Index: src/hosts.c
51 --- src/hosts.c 31 Mar 2003 07:42:28 -0000      1.29
52 +++ src/hosts.c 2 Apr 2003 02:42:27 -0000
53 @@ -157,21 +157,43 @@
54      return 0;
55  }
56  
57 -static int dcc_parse_multiplier(const char **psrc, struct dcc_hostdef *hostdef)
58 +static int dcc_parse_options(const char **psrc, struct dcc_hostdef *hostdef)
59  {
60 -    char *mul;
61 -    const char *token = *psrc;
62 +    char *opt, *arg;
63 +    const char *token;
64      int ret;
65  
66 -    if ((*psrc)[0] == '/') {
67 -        (*psrc)++;
68 -        if ((ret = dcc_dup_part(psrc, &mul, "/: \t\n\f")) != 0)
69 +    while ((*psrc)[0] == ',') {
70 +        token = (*psrc)++;
71 +        if ((ret = dcc_dup_part(psrc, &opt, ", \t\n\f")) != 0)
72              return ret;
73 -        if (!mul || atoi(mul) == 0) {
74 -            rs_log_error("bad multiplier \"%s\" in host specification", token);
75 +        if (opt) {
76 +            if ((arg = strchr(opt, '=')) != NULL)
77 +                *arg++ = '\0';
78 +            else if (isdigit(*opt)) {
79 +                arg = opt;
80 +                opt = NULL;
81 +            }
82 +            else
83 +                arg = NULL;
84 +        }
85 +        else
86 +            arg = NULL;
87 +        if (!arg) {
88 +            rs_log_error("malformed option in host specification: \"%s\"", token);
89 +            return EXIT_BAD_HOSTSPEC;
90 +        }
91 +        if (!opt || strcmp(opt, "slots") == 0) {
92 +            hostdef->n_slots = atoi(arg);
93 +            if (hostdef->n_slots <= 0) {
94 +                rs_log_error("invalid number of slots in host specification: \"%s\"", token);
95 +                return EXIT_BAD_HOSTSPEC;
96 +            }
97 +        }
98 +        else {
99 +            rs_log_error("unknown option in host specification: \"%s\"", token);
100              return EXIT_BAD_HOSTSPEC;
101          }
102 -        hostdef->n_slots = atoi(mul);
103      }
104      return 0;
105  }
106 @@ -189,7 +211,7 @@
107      assert(token[0] == '@');
108      token++;
109  
110 -    if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
111 +    if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
112          return ret;
113  
114      if (!hostdef->hostname) {
115 @@ -198,15 +220,15 @@
116          return EXIT_BAD_HOSTSPEC;
117      }
118  
119 -    if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
120 -        return ret;
121 -
122      if (token[0] == ':') {
123          token++;
124 -        if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, " \t\n\f")) != 0)
125 +        if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, ", \t\n\f")) != 0)
126              return ret;
127      }
128 -    
129 +
130 +    if ((ret = dcc_parse_options(&token, hostdef)) != 0)
131 +        return ret;
132 +
133      hostdef->mode = DCC_MODE_SSH;
134      return 0;
135  }
136 @@ -219,7 +241,7 @@
137      int ret;
138      const char *token = token_start;
139      
140 -    if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
141 +    if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
142          return ret;
143  
144      if (!hostdef->hostname) {
145 @@ -228,14 +250,11 @@
146          return EXIT_BAD_HOSTSPEC;
147      }
148  
149 -    if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
150 -        return ret;
151 -
152      hostdef->port = dcc_default_port;
153      if (token[0] == ':') {
154          token++;
155  
156 -        if ((ret = dcc_dup_part(&token, &port_str, " \t\n\f")) != 0)
157 +        if ((ret = dcc_dup_part(&token, &port_str, ", \t\n\f")) != 0)
158              return ret;
159          
160          if (port_str) {
161 @@ -248,7 +267,10 @@
162              free(port_str);
163          }
164      }
165 -        
166 +
167 +    if ((ret = dcc_parse_options(&token, hostdef)) != 0)
168 +        return ret;
169 +
170      hostdef->mode = DCC_MODE_TCP;
171      return 0;
172  }
173 @@ -257,13 +279,13 @@
174  static int dcc_parse_localhost(struct dcc_hostdef *hostdef,
175                                 const char * token_start)
176  {
177 -    const char *token = token_start + strlen("localhost");
178 +    const char *token = token_start + (sizeof "localhost") - 1;
179  
180      hostdef->mode = DCC_MODE_LOCAL;
181      hostdef->hostname = strdup("localhost");
182      hostdef->n_slots = 1;
183      
184 -    return dcc_parse_multiplier(&token, hostdef);
185 +    return dcc_parse_options(&token, hostdef);
186  }
187  
188  
189 @@ -294,7 +316,7 @@
190       * definition.  We then duplicate the relevant subcomponents into
191       * the relevant fields. */
192      while (1) {
193 -        int token_len;
194 +        unsigned int token_len;
195          const char *token_start;
196          int has_at;
197          
198 @@ -326,8 +348,10 @@
199          has_at = (memchr(token_start, '@', token_len) != NULL);
200          /* TODO: Call a separate function to split each type up, then
201           * link the result into the list. */
202 -        if (!strncmp(token_start, "localhost", token_len)
203 -            || !strncmp(token_start, "localhost/", strlen("localhost/"))) {
204 +        if (token_len >= (sizeof "localhost")-1
205 +            && strncmp(token_start, "localhost", (sizeof "localhost")-1) == 0
206 +            && (token_len == (sizeof "localhost")-1
207 +             || token_start[(sizeof "localhost")-1] == ',')) {
208              if ((ret = dcc_parse_localhost(curr, token_start)) != 0)
209                  return ret;
210          } else if (has_at) {
This page took 0.093212 seconds and 4 git commands to generate.