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
santa-driver: add an acknowledge feature to allow timeouts #220
Conversation
tburgin
commented
Nov 27, 2017
- lost requests will be retried
- acknowledged requests will wait forever for a response - only large binaries generate an acknowledgement
/** | ||
While waiting for a response from the daemon, this is the maximum number cache checks before | ||
re-sending the request. | ||
*/ |
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.
indent -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.
Done
@@ -144,6 +144,12 @@ class SantaDecisionManager : public OSObject { | |||
*/ | |||
static const uint32_t kRequestLoopSleepMilliseconds = 1000; | |||
|
|||
/** | |||
While waiting for a response from the daemon, this is the maximum number cache checks before | |||
re-sending the request. |
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.
Indent both lines +2
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.
+1 Done.
} while (return_action == ACTION_REQUEST_BINARY && ClientConnected()); | ||
if (return_action == ACTION_REQUEST_BINARY) ++cache_check_count; | ||
} while ((return_action == ACTION_REQUEST_BINARY || return_action == ACTION_RESPOND_ACK) | ||
&& ClientConnected() && cache_check_count < kRequestCacheChecks); |
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 think the condition here can include the cache_check_count increment too without being less clear. Maybe this:
} while (ClientConnected() &&
((return_action == ACTION_REQUEST_BINARY && ++cache_check_count < kRequestCacheChecks) ||
(return_action == ACTION_RESPOND_ACK)));
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.
Yeah, that's nicer. Except the || is over 100 lines :(
case ACTION_RESPOND_ALLOW: | ||
case ACTION_RESPOND_DENY: | ||
decision_cache->set( | ||
identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56)); | ||
if (decision_cache->set(identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56))) { |
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.
Can you add a TODO above this line to make calling set twice unnecessary - having both calls will involve finding and locking the bucket (or buckets) multiple times.
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.
Done.
@@ -38,6 +38,8 @@ | |||
#import "SNTStoredEvent.h" | |||
#import "SNTSyncdQueue.h" | |||
|
|||
static size_t kLargeBinarySize = 30 * 1024 * 1024; |
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.
Add a brief comment.
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.
Done.
Tests/KernelTests/main.mm
Outdated
@@ -239,6 +242,18 @@ - (void)beginListening { | |||
} else if (strncmp("/bin/cat", vdata.path, strlen("/bin/cat")) == 0) { | |||
[self postToKernelAction:ACTION_RESPOND_ALLOW forVnodeID:vdata.vnode_id]; | |||
self.timesSeenCat++; | |||
} else if (strncmp("/usr/bin/cal", vdata.path, strlen("/usr/bin/cal")) == 0) { | |||
static int count; |
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.
init to 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.
Done
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
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.
PTAL
case ACTION_RESPOND_ALLOW: | ||
case ACTION_RESPOND_DENY: | ||
decision_cache->set( | ||
identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56)); | ||
if (decision_cache->set(identifier, val, ((uint64_t)ACTION_REQUEST_BINARY << 56))) { |
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.
Done.
} while (return_action == ACTION_REQUEST_BINARY && ClientConnected()); | ||
if (return_action == ACTION_REQUEST_BINARY) ++cache_check_count; | ||
} while ((return_action == ACTION_REQUEST_BINARY || return_action == ACTION_RESPOND_ACK) | ||
&& ClientConnected() && cache_check_count < kRequestCacheChecks); |
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.
Yeah, that's nicer. Except the || is over 100 lines :(
@@ -144,6 +144,12 @@ class SantaDecisionManager : public OSObject { | |||
*/ | |||
static const uint32_t kRequestLoopSleepMilliseconds = 1000; | |||
|
|||
/** | |||
While waiting for a response from the daemon, this is the maximum number cache checks before | |||
re-sending the request. |
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.
+1 Done.
/** | ||
While waiting for a response from the daemon, this is the maximum number cache checks before | ||
re-sending the request. | ||
*/ |
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.
Done
@@ -38,6 +38,8 @@ | |||
#import "SNTStoredEvent.h" | |||
#import "SNTSyncdQueue.h" | |||
|
|||
static size_t kLargeBinarySize = 30 * 1024 * 1024; |
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.
Done.
Tests/KernelTests/main.mm
Outdated
@@ -239,6 +242,18 @@ - (void)beginListening { | |||
} else if (strncmp("/bin/cat", vdata.path, strlen("/bin/cat")) == 0) { | |||
[self postToKernelAction:ACTION_RESPOND_ALLOW forVnodeID:vdata.vnode_id]; | |||
self.timesSeenCat++; | |||
} else if (strncmp("/usr/bin/cal", vdata.path, strlen("/usr/bin/cal")) == 0) { | |||
static int count; |
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.
Done
* santa-driver: Add an acknowledge feature to allow timeouts for lost requests * project: cocoapods 1.3.1 update * review updates