Skip to content

Commit aa9bff2

Browse files
committed
ENETDOWN and ENETUNREACH are temporary failures
We might want to discard the data instead of saving it, especially for UDP. Or, put the packet into a pending queue, which can then be written later, or else timed out.
1 parent 3a70a07 commit aa9bff2

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/lib/io/network.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,16 +1243,35 @@ static void fr_network_write(UNUSED fr_event_list_t *el, UNUSED int sockfd, UNUS
12431243

12441244
PERROR("Failed writing to socket %s", s->listen->name);
12451245

1246+
switch (errno) {
12461247
/*
12471248
* As a special hack, check for something
12481249
* that will never be returned from a
12491250
* real write() routine. Which then
12501251
* signals to us that we have to close
12511252
* the socket, but NOT complain about it.
12521253
*/
1253-
if ((errno == ECONNREFUSED) || (errno == ECONNRESET)) goto dead;
1254+
case ECONNREFUSED:
1255+
case ECONNRESET:
1256+
break;
1257+
1258+
/*
1259+
* These are temporary errors. We try to save the data for later.
1260+
*/
1261+
case ENETDOWN:
1262+
case ENETUNREACH:
1263+
if (s->pending) {
1264+
fr_message_done(&cd->m);
1265+
return;
1266+
}
1267+
1268+
s->written = rcode = 0;
1269+
goto save_pending;
12541270

1255-
if (li->app_io->error) li->app_io->error(li);
1271+
default:
1272+
if (li->app_io->error) li->app_io->error(li);
1273+
break;
1274+
}
12561275

12571276
dead:
12581277
fr_message_done(&cd->m);

0 commit comments

Comments
 (0)