Show More
@@ -31,6 +31,7 b'' | |||
|
31 | 31 | |
|
32 | 32 | struct cmdserveropts { |
|
33 | 33 | char sockname[UNIX_PATH_MAX]; |
|
34 | char initsockname[UNIX_PATH_MAX]; | |
|
34 | 35 | char redirectsockname[UNIX_PATH_MAX]; |
|
35 | 36 | char lockfile[UNIX_PATH_MAX]; |
|
36 | 37 | size_t argsize; |
@@ -163,6 +164,10 b' static void setcmdserveropts(struct cmds' | |||
|
163 | 164 | r = snprintf(opts->lockfile, sizeof(opts->lockfile), lockfmt, basename); |
|
164 | 165 | if (r < 0 || (size_t)r >= sizeof(opts->lockfile)) |
|
165 | 166 | abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r); |
|
167 | r = snprintf(opts->initsockname, sizeof(opts->initsockname), | |
|
168 | "%s.%u", opts->sockname, (unsigned)getpid()); | |
|
169 | if (r < 0 || (size_t)r >= sizeof(opts->initsockname)) | |
|
170 | abortmsg("too long TMPDIR or CHGSOCKNAME (r = %d)", r); | |
|
166 | 171 | } |
|
167 | 172 | |
|
168 | 173 | /* |
@@ -223,7 +228,7 b' static void execcmdserver(const struct c' | |||
|
223 | 228 | hgcmd, |
|
224 | 229 | "serve", |
|
225 | 230 | "--cmdserver", "chgunix", |
|
226 | "--address", opts->sockname, | |
|
231 | "--address", opts->initsockname, | |
|
227 | 232 | "--daemon-postexec", "chdir:/", |
|
228 | 233 | }; |
|
229 | 234 | size_t baseargvsize = sizeof(baseargv) / sizeof(baseargv[0]); |
@@ -247,7 +252,7 b' static hgclient_t *retryconnectcmdserver' | |||
|
247 | 252 | static const struct timespec sleepreq = {0, 10 * 1000000}; |
|
248 | 253 | int pst = 0; |
|
249 | 254 | |
|
250 | debugmsg("try connect to %s repeatedly", opts->sockname); | |
|
255 | debugmsg("try connect to %s repeatedly", opts->initsockname); | |
|
251 | 256 | |
|
252 | 257 | unsigned int timeoutsec = 60; /* default: 60 seconds */ |
|
253 | 258 | const char *timeoutenv = getenv("CHGTIMEOUT"); |
@@ -255,9 +260,15 b' static hgclient_t *retryconnectcmdserver' | |||
|
255 | 260 | sscanf(timeoutenv, "%u", &timeoutsec); |
|
256 | 261 | |
|
257 | 262 | for (unsigned int i = 0; !timeoutsec || i < timeoutsec * 100; i++) { |
|
258 | hgclient_t *hgc = hgc_open(opts->sockname); | |
|
259 | if (hgc) | |
|
263 | hgclient_t *hgc = hgc_open(opts->initsockname); | |
|
264 | if (hgc) { | |
|
265 | debugmsg("rename %s to %s", opts->initsockname, | |
|
266 | opts->sockname); | |
|
267 | int r = rename(opts->initsockname, opts->sockname); | |
|
268 | if (r != 0) | |
|
269 | abortmsgerrno("cannot rename"); | |
|
260 | 270 | return hgc; |
|
271 | } | |
|
261 | 272 | |
|
262 | 273 | if (pid > 0) { |
|
263 | 274 | /* collect zombie if child process fails to start */ |
@@ -269,7 +280,7 b' static hgclient_t *retryconnectcmdserver' | |||
|
269 | 280 | nanosleep(&sleepreq, NULL); |
|
270 | 281 | } |
|
271 | 282 | |
|
272 | abortmsg("timed out waiting for cmdserver %s", opts->sockname); | |
|
283 | abortmsg("timed out waiting for cmdserver %s", opts->initsockname); | |
|
273 | 284 | return NULL; |
|
274 | 285 | |
|
275 | 286 | cleanup: |
@@ -312,7 +323,7 b' static hgclient_t *connectcmdserver(stru' | |||
|
312 | 323 | if (sockname == opts->redirectsockname) |
|
313 | 324 | unlink(opts->sockname); |
|
314 | 325 | |
|
315 | debugmsg("start cmdserver at %s", opts->sockname); | |
|
326 | debugmsg("start cmdserver at %s", opts->initsockname); | |
|
316 | 327 | |
|
317 | 328 | pid_t pid = fork(); |
|
318 | 329 | if (pid < 0) |
@@ -46,7 +46,7 b' isolate socket directory for stable resu' | |||
|
46 | 46 | warm up server: |
|
47 | 47 | |
|
48 | 48 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
49 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server | |
|
49 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
|
50 | 50 | |
|
51 | 51 | new server should be started if extension modified: |
|
52 | 52 | |
@@ -55,7 +55,7 b' new server should be started if extensio' | |||
|
55 | 55 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
56 | 56 | chg: debug: instruction: unlink $TESTTMP/extreload/chgsock/server-* (glob) |
|
57 | 57 | chg: debug: instruction: reconnect |
|
58 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server | |
|
58 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
|
59 | 59 | |
|
60 | 60 | old server will shut down, while new server should still be reachable: |
|
61 | 61 | |
@@ -77,7 +77,7 b' since no server is reachable from socket' | |||
|
77 | 77 | (this test makes sure that old server shut down automatically) |
|
78 | 78 | |
|
79 | 79 | $ CHGDEBUG= chg log 2>&1 | egrep 'instruction|start' |
|
80 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server | |
|
80 | chg: debug: start cmdserver at $TESTTMP/extreload/chgsock/server.* (glob) | |
|
81 | 81 | |
|
82 | 82 | shut down servers and restore environment: |
|
83 | 83 |
General Comments 0
You need to be logged in to leave comments.
Login now