*/
static int send_one_packet(fr_bio_packet_t *client, rc_request_t *request)
{
+ int rcode;
+
fr_assert(!request->done);
fr_assert(request->reply == NULL);
request->timestamp = fr_time();
request->tries = 1;
- request->resend++;
/*
* Send the current packet.
*/
- if (fr_bio_packet_write(client, request, request->packet, &request->request_pairs) < 0) {
+ rcode = fr_bio_packet_write(client, request, request->packet, &request->request_pairs);
+ if (rcode < 0) {
+ /*
+ * Failed writing it. Try again later.
+ */
+ if (rcode == fr_bio_error(IO_WOULD_BLOCK)) return 0;
+
REDEBUG("Failed writing packet - %s", fr_strerror());
return -1;
}
return;
}
- current = request;
-
if (request->packet->id >= 0) {
paused = true;
goto pause;
}
request->resend++;
+ current = request;
+
}
static void client_connect(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
if (fr_packet_sign(packet, NULL, (char const *) my->cfg.verify.secret) < 0) goto fail;
slen = fr_bio_write(my->common.bio, &packet->socket, packet->data, packet->data_len);
- if (slen <= 0) {
+ if (slen < 0) {
fr_radius_code_id_push(my->codes, packet);
return slen;
}
+ /*
+ * Didn't write anything, that's a blocking error.
+ */
+ if (slen == 0) {
+ fr_radius_code_id_push(my->codes, packet);
+ return fr_bio_error(IO_WOULD_BLOCK);
+ }
+
my->info.outstanding++;
return 0;