Skip to content

Commit 1dbe00e

Browse files
committed
clarify atomicity of getRawNMM
1 parent 3f9e3d3 commit 1dbe00e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

storage.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ bool getNMM(FILE* fp, NavMonMessage& nmm, uint32_t& offset)
8080
return true;
8181
}
8282

83+
// if you rely on offset, this function is atomic wrt partial reads,
84+
// the offset will only get updated on a whole message
8385
bool getRawNMM(int fd, timespec& t, string& raw, uint32_t& offset)
8486
{
8587
char bert[4];
8688
int res;
8789
if((res=read(fd, bert, 4)) != 4 || bert[0]!='b' || bert[1]!='e' || bert[2] !='r' || bert[3]!='t') {
88-
if(res != 4)
90+
if(res != 4) {
8991
return false;
92+
}
9093

9194
for(int s=0;; ++s ) {
9295
cerr<<"Skipping character hunting for good magic.. "<<s<<endl;

0 commit comments

Comments
 (0)