summaryrefslogtreecommitdiffstats
path: root/src/shared/protocol.h
diff options
context:
space:
mode:
authorSimon Rettberg2015-11-30 17:31:06 +0100
committerSimon Rettberg2015-11-30 17:31:06 +0100
commit1d0211719bc6ad76f924f8c08e1a28f0509cd4fd (patch)
tree58b8f520514357bb689c781bcaa717092649b03e /src/shared/protocol.h
parent[FUSE] Compiles again (diff)
downloaddnbd3-1d0211719bc6ad76f924f8c08e1a28f0509cd4fd.tar.gz
dnbd3-1d0211719bc6ad76f924f8c08e1a28f0509cd4fd.tar.xz
dnbd3-1d0211719bc6ad76f924f8c08e1a28f0509cd4fd.zip
[FUSE] It works! Kinda...
Diffstat (limited to 'src/shared/protocol.h')
-rw-r--r--src/shared/protocol.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/shared/protocol.h b/src/shared/protocol.h
index 41e9af2..a5c7bbd 100644
--- a/src/shared/protocol.h
+++ b/src/shared/protocol.h
@@ -35,6 +35,8 @@ static inline int dnbd3_read_reply(int sock, dnbd3_reply_t *reply, bool wait)
static inline bool dnbd3_get_reply(int sock, dnbd3_reply_t *reply)
{
+ int ret = dnbd3_read_reply( sock, reply, true );
+ if ( ret != REPLY_INTR ) return ret == REPLY_OK;
return dnbd3_read_reply( sock, reply, true ) == REPLY_OK;
}
@@ -61,7 +63,11 @@ static inline bool dnbd3_select_image(int sock, const char *lower_name, uint16_t
iov[0].iov_len = sizeof(request);
iov[1].iov_base = &serialized;
iov[1].iov_len = len;
- return writev( sock, iov, 2 ) == len + (ssize_t)sizeof(request);
+ ssize_t ret = writev( sock, iov, 2 );
+ if ( ret == -1 && errno == EINTR ) {
+ ret = writev( sock, iov, 2 );
+ }
+ return ret == len + (ssize_t)sizeof(request);
}
static inline bool dnbd3_get_block(int sock, uint64_t offset, uint32_t size, uint64_t handle)
@@ -123,7 +129,11 @@ static inline bool dnbd3_select_image_reply(serialized_buffer_t *buffer, int soc
return false;
}
// receive reply payload
- if ( recv( sock, buffer, reply.size, MSG_WAITALL | MSG_NOSIGNAL ) != reply.size ) {
+ ssize_t ret = recv( sock, buffer, reply.size, MSG_WAITALL | MSG_NOSIGNAL );
+ if ( ret == -1 && errno == EINTR ) {
+ ret = recv( sock, buffer, reply.size, MSG_WAITALL | MSG_NOSIGNAL );
+ }
+ if ( ret != reply.size ) {
return false;
}
// handle/check reply payload