-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add Rids Synchronization #459
Conversation
f6871c4
to
5fb02b1
Compare
src/os_crypto/shared/msgs.c
Outdated
@@ -90,6 +92,7 @@ void OS_StartCounter(keystore *keys) | |||
} | |||
|
|||
keys->keyentries[i]->fp = fopen(rids_file, "r+"); | |||
keys->keyentries[i]->inode = File_Inode(rids_file); | |||
|
|||
/* If nothing is there, try to open as write only */ | |||
if (!keys->keyentries[i]->fp) { |
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.
Missing File_Inode()
here, if fopen()
failed. This call may be better after ending the if
block (just like you did in ReloadCounter()
.
src/os_crypto/shared/msgs.c
Outdated
} | ||
|
||
/* Reload the global and local count of events */ | ||
static void ReloadCounter(const keystore *keys, int id, const char * cid) |
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.
This function does not update global_count
or local_count
. Those variables must be updated instead of the agent counters in the case that id==keysize
.
src/os_crypto/shared/msgs.c
Outdated
@@ -315,6 +356,7 @@ char *ReadSecMSG(keystore *keys, char *buffer, char *cleartext, int id, unsigned | |||
keys->keyentries[id]->local = msg_local; | |||
|
|||
if (rcv_count >= _s_recv_flush) { | |||
ReloadCounter(keys, id, keys->keyentries[id]->id); |
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.
The agent counter must be updated before comparing the message counter.
src/os_crypto/shared/msgs.c
Outdated
@@ -462,6 +504,10 @@ size_t CreateSecMSG(const keystore *keys, const char *msg, size_t msg_length, ch | |||
_finmsg[OS_MAXSTR + 1] = '\0'; | |||
msg_encrypted[OS_MAXSTR] = '\0'; | |||
|
|||
if (snd_count >= _s_recv_flush) { | |||
ReloadCounter(keys, keys->keysize, SENDER_COUNTER); |
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.
This call must update global_counter
and local_counter
.
GJ @bah07 !! |
This PR add feature related issue #456
ino_t inode
to store each agent's counter inodeReloadCounter
function checks if the inode of the file has changed, if so, reloads the corresponding counters.