File tree 1 file changed +13
-12
lines changed
contrib/raftable/raft/src 1 file changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -1128,7 +1128,9 @@ static char buf[UDP_SAFE_SIZE];
1128
1128
1129
1129
raft_msg_t raft_recv_message (raft_t r ) {
1130
1130
struct sockaddr_in addr ;
1131
- unsigned int addrlen = sizeof (addr );
1131
+ unsigned int addrlen ;
1132
+ tryagain :
1133
+ addrlen = sizeof (addr );
1132
1134
1133
1135
//try to receive some data
1134
1136
raft_msg_t m = (raft_msg_t )buf ;
@@ -1137,17 +1139,16 @@ raft_msg_t raft_recv_message(raft_t r) {
1137
1139
(struct sockaddr * )& addr , & addrlen
1138
1140
);
1139
1141
1140
- if (recved <= 0 ) {
1141
- if (
1142
- (errno == EAGAIN ) ||
1143
- (errno == EWOULDBLOCK ) ||
1144
- (errno == EINTR )
1145
- ) {
1146
- return NULL ;
1147
- } else {
1148
- shout ("failed to recv: %s\n" , strerror (errno ));
1149
- return NULL ;
1150
- }
1142
+ if (recved < 0 ) {
1143
+ if (errno == EINTR ) goto tryagain ;
1144
+ if ((errno == EAGAIN ) || (errno == EWOULDBLOCK )) return NULL ;
1145
+ shout ("failed to recv: %s\n" , strerror (errno ));
1146
+ return NULL ;
1147
+ }
1148
+
1149
+ if (recved == 0 ) {
1150
+ shout ("failed to recv: recved 0 bytes\n" );
1151
+ return NULL ;
1151
1152
}
1152
1153
1153
1154
if (!msg_size_is (m , recved )) {
You can’t perform that action at this time.
0 commit comments