-
Notifications
You must be signed in to change notification settings - Fork 6
ci: build and test tntcxx on macos 11 and 12 #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c4bb4b8
f703e16
e77f6f1
91d7980
2b2549a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,8 @@ set_parent_death_signal(pid_t ppid_before_fork, const char *child_program_name) | |
} | ||
} | ||
|
||
#ifdef __linux__ | ||
|
||
inline int | ||
launchTarantool(bool enable_ssl = false) | ||
{ | ||
|
@@ -85,6 +87,64 @@ launchTarantool(bool enable_ssl = false) | |
exit(EXIT_FAILURE); | ||
} | ||
|
||
#else | ||
|
||
/** | ||
* Launches intermediate process, connected with parent by pipe. | ||
* The intermediate process lauches another process, running tarantool, and then | ||
* falls asleep on reading from pipe. When parent process is dead, the pipe | ||
* will be closed, and the intermediate process will read EOF. Right after, it | ||
* will kill its child process, which is Tarantool, and exit. | ||
* In the case, when the intermediate process fails to fork Tarantool, it kills | ||
* the parent process and terminates. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @alyapunov in the sense that this is code is really sophistacted, but I guess there is no other way to implement this approach on macOS, so I see two ways to make life easier for us:
FootnotesThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
go-tarantool is also unable to shutdown Tarantool processes in case of a crash now, so this problem is unresolved for us as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is an implementation flaw. It could be implemented in Go for But there is no solution to the problem in go-tarantool that would be suitable for C++. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you think that a process leak happens? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I mean if we go for option 2 that I listed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I also thought about this, we could add signal handlers from recoverable signals (i.e., even go can't do anything about Another path we can take is setting up and cleaning up Tarantool externally (i.e., via the test harness or some shell scripting), but it may not be scalable or convenient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's time for @alyapunov to take the decision how we should proceed here. |
||
inline int | ||
launchTarantool(bool enable_ssl = false) | ||
{ | ||
pid_t ppid_before_fork = getpid(); | ||
int p[2]; | ||
pipe(p); | ||
pid_t pid = fork(); | ||
if (pid == -1) { | ||
fprintf(stderr, "Can't launch Tarantool: fork failed! %s", | ||
strerror(errno)); | ||
return -1; | ||
} | ||
/* Returning from parent. */ | ||
if (pid != 0) | ||
return 0; | ||
|
||
/* | ||
* It is necessary to close write end of pipe here if we want to read | ||
* EOF when the parent process is dead. | ||
*/ | ||
close(p[1]); | ||
pid = fork(); | ||
if (pid == -1) { | ||
/* | ||
* We've already returned OK in the parent, so let's kill it if | ||
* the intermediate process fails to fork Tarantool. | ||
*/ | ||
kill(ppid_before_fork, SIGKILL); | ||
exit(EXIT_FAILURE); | ||
} | ||
if (pid == 0) { | ||
close(p[0]); | ||
const char *script = enable_ssl ? "test_cfg_ssl.lua" : "test_cfg.lua"; | ||
if (execlp("tarantool", "tarantool", script, NULL) == -1) { | ||
fprintf(stderr, "Can't launch Tarantool: execlp failed! %s\n", | ||
strerror(errno)); | ||
kill(getppid(), SIGKILL); | ||
} | ||
} | ||
char buf[1]; | ||
read(p[0], buf, 1); | ||
kill(pid, SIGTERM); | ||
exit(0); | ||
} | ||
|
||
#endif | ||
|
||
inline int | ||
cleanDir() { | ||
pid_t pid = fork(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[feel free to ignore, just for your knowledge]
Nit: you could use the
${{ matrix.test-ssl == 'Disabled' && 'ClientSSL.test' || ''}}
ternary operator syntax (see example here) just like in Lua to simplify the code and have less branches.