Skip to content

Commit 1126825

Browse files
committed
fabrics: retry connect command on EINTR
Recent changes in the nvme-tcp transport started to return EINTR due to a signal while reading from a socket. The transport could retry the operation but so far this hasn't been implemented. Thus we retry in userpace the connect call when EINTR is returned. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 56ca8b4 commit 1126825

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ else
243243
conf.set('fallthrough', 'do {} while (0) /* fallthrough */')
244244
endif
245245

246+
if cc.has_function('TEMP_FAILURE_RETRY', prefix : '#include <errno.h>')
247+
conf.set('TFR', 'TEMP_FAILURE_RETRY')
248+
else
249+
conf.set('TFR(exp)', ''' \
250+
({ \
251+
long int __result = 0; \
252+
do { \
253+
__result = (long int)(exp); \
254+
} while ((__result == -1) && (errno == EINTR)); \
255+
__result; \
256+
})
257+
''')
258+
endif
259+
246260
################################################################################
247261
substs = configuration_data()
248262
substs.set('NAME', meson.project_name())

src/nvme/fabrics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr)
814814

815815
nvme_msg(r, LOG_DEBUG, "connect ctrl, '%.*s'\n",
816816
(int)strcspn(argstr,"\n"), argstr);
817-
ret = write(fd, argstr, len);
817+
ret = TFR(write(fd, argstr, len));
818818
if (ret != len) {
819819
nvme_msg(r, LOG_INFO, "Failed to write to %s: %s\n",
820820
nvmf_dev, strerror(errno));

0 commit comments

Comments
 (0)