Skip to content

Commit 9a08f51

Browse files
committed
fabrics: retry connect command on EINTR
When the system call fails with EINTR, retry the operation. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 56ca8b4 commit 9a08f51

2 files changed

Lines changed: 16 additions & 2 deletions

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int __nvmf_add_ctrl(nvme_root_t r, const char *argstr)
805805
int ret, len = strlen(argstr);
806806
char buf[0x1000], *options, *p;
807807

808-
fd = open(nvmf_dev, O_RDWR);
808+
fd = TFR(open(nvmf_dev, O_RDWR));
809809
if (fd < 0) {
810810
nvme_msg(r, LOG_ERR, "Failed to open %s: %s\n",
811811
nvmf_dev, strerror(errno));
@@ -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)