Closed staskysel closed 1 year ago
Looks good to me, Im running test to try and duplicate the scenario you described right now so I can get a before and after verification. Sorry about the delay!
Looks good here, and you're right I had to get something like 120 agents registering at once to hit this one
Hi. I'm a newbie here, so please forgive me, if I fail to follow some kind of "code of conduct".
In
send_msg()
,CreateSecMSG()
uses (for persisting sender counter)keys
structure, which can be modified by main thread callingOS_UpdateKeys()
. Thus main thread can interfere with manager thread callingCreateSecMSG()
.To fix this,
CreateSecMSG()
must be called after obtainingsendmsg_mutex
lock.Otherwise under certain circumstances, quite common when adding new agents, an existing agent's counter is overwritten by sender counter e.g. in the following scenario:
Main thread (
HandleSecure()
):check_keyupdate()
OS_UpdateKeys()
OS_FreeKeys()
keys.keysize = 0
sleep(1)
, thus transferring control to the main thread and increasing probability of the following.Manager thread:
CreateSecMSG()
(e.g. fromsend_msg()
called fromsend_file_toagent()
called fromread_controlmsg()
called fromwait_for_msgs()
)StoreSenderCounter()
, which stores sender counter tokeys->keyentries[keys->keysize]->fp
keys->keysize
is 0, instead of writing to "queue/rids/sender_counter" file, the counter is written to "queue/rids/NNN", where NNN is the lowest agent ID.