-
Notifications
You must be signed in to change notification settings - Fork 138
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
Issue 202 #205
Issue 202 #205
Conversation
The only problem with this approach is that I think using |
|
It's done in 6ca3f04 |
This is probably fine, but potentially creating a temp file in |
util/signal.cc
Outdated
mktemp(lock_name); | ||
// random lock_name required | ||
if (mkstemp(lock_name) != -1) | ||
{ |
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.
Braces doesn't appear to line up properly here. The open brace should be under the "i" in "if". Double check indentation on the next several lines as well.
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.
mkstemp
based approach is removed. The braces also.
Unfortunately Travis CI tests failing with new random string based approach. They are running fine locally.
Tests failing... Another option might be to revert the code way back to using unnamed semaphores and only use the named semaphores approach on macOS. |
I thought about this also. Actually there is no evidence named semaphores cause the issue. Maybe the content of |
I've been thinking that it might be useful if Travis CI were to |
according to http://man7.org/linux/man-pages/man3/sem_open.3.html If O_CREAT is specified, then two additional arguments must be supplied
Ah, ha! The man page for |
Yes, I did. We could merge the PR yet. |
libtest/signal.cc
Outdated
thread_local static std::mt19937 rg{std::random_device{}()}; | ||
thread_local static std::uniform_int_distribution<std::string::size_type> pick(0, sizeof(chrs) - 2); | ||
|
||
// convenient to named semaphore defination |
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.
Misspelled "definition" here.
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.
Also, could you can a blank line after the "break;" for "case SIGQUIT" (right before "case SIGPIPE")? Not in the scope of your changes, but it's trivial.
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.
There is no blank at the end of case SIGQUIT
. Do you mean case SIGPIPE
?
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.
I was hoping you'd add a blank line after this line:
Line 199 in a333f31
break; |
But too late now that we've merged....
util/signal.cc
Outdated
std::string s{"/"}; | ||
s.reserve(len--); | ||
|
||
while(len--) |
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.
There should be a space between "while" and "(".
libtest/signal.cc
Outdated
lock = sem_open(lock_name, O_CREAT|O_EXCL); | ||
|
||
const char * lock_name = random_lock_name().c_str(); | ||
lock = sem_open(lock_name, O_CREAT|O_EXCL, 0660, 0); |
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.
Instead of 0660
, use S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP
instead?
I think those S_*
constants are defined in sys/stat.h
?
#include <sys/stat.h>
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.
OK
libtest/signal.cc
Outdated
std::string s{"/"}; | ||
s.reserve(len--); | ||
|
||
while(len--) |
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.
There should be a space between "while" and "(".
s.reserve(len--); | ||
|
||
while(len--) | ||
s += chrs[pick(rg)]; |
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.
Something tells me that the coding style for this project is to put braces around single statement loops like this. Please confirm.
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.
I'll add the braces.
s.reserve(len--); | ||
|
||
while(len--) | ||
s += chrs[pick(rg)]; |
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.
Something tells me that the coding style for this project is to put braces around single statement loops like this. Please confirm.
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.
I'll add the braces
Also, shouldn't this line be changed? Line 230 in ed3d03b
I'm not aware of a 3-argument version of sem_open. Only 2 and 4 arguments, right? I'm surprised this even compiles. Don't we want |
And, not that it matters, but I'm curious why |
We'll see, if |
util/signal.cc
Outdated
@@ -243,7 +245,7 @@ bool SignalThread::setup() | |||
} | |||
|
|||
const char * lock_name = random_lock_name().c_str(); | |||
lock = sem_open(lock_name, 0, 0); | |||
lock = sem_open(lock_name, O_CREAT, S_IRUSR|S_IWUSR, 0); |
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.
No |O_EXCL
here?
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.
Oh, yes
For some reason I can't reopen #203.
The PR do the same:
mktemp' is dangerous, better use
mkstemp' or `mkdtemp #202.