added an interim solution to sendto failure in dns and urs handling

This commit is contained in:
hyung-hwan 2014-09-29 14:17:44 +00:00
parent 0cd8dfe54c
commit 96f42a0815
2 changed files with 39 additions and 6 deletions

View File

@ -831,9 +831,18 @@ printf (">>tmr_dns_tmout_handle req->>%p\n", req);
(!(req->flags & DNS_REQ_AAAA_NX) && req->qaaaalen > 0 && sendto (req->dns_socket, req->qaaaa, req->qaaaalen, 0, (struct sockaddr*)&req->dns_skad, req->dns_skadlen) != req->qaaaalen)) (!(req->flags & DNS_REQ_AAAA_NX) && req->qaaaalen > 0 && sendto (req->dns_socket, req->qaaaa, req->qaaaalen, 0, (struct sockaddr*)&req->dns_skad, req->dns_skadlen) != req->qaaaalen))
{ {
/* resend failed. fall thru and destroy the request*/ /* resend failed. fall thru and destroy the request*/
/* Unix datagram socket seems to fail with EAGAIN often
* even with increased SO_SNDBUF size. */
if (dc->httpd->errnum == QSE_HTTPD_EAGAIN && req->dns_retries > 1)
{
/* TODO: check writability of req->urs_socket instead of just retrying... */
goto send_ok;
}
} }
else else
{ {
send_ok:
QSE_ASSERT (tmr == dc->httpd->tmr); QSE_ASSERT (tmr == dc->httpd->tmr);
if (qse_httpd_inserttimerevent (dc->httpd, &tmout_event, &req->tmr_tmout) >= 0) if (qse_httpd_inserttimerevent (dc->httpd, &tmout_event, &req->tmr_tmout) >= 0)
{ {
@ -992,10 +1001,19 @@ static int dns_send (qse_httpd_t* httpd, qse_httpd_dns_t* dns, const qse_mchar_t
(req->qaaaalen > 0 && sendto (req->dns_socket, req->qaaaa, req->qaaaalen, 0, (struct sockaddr*)&req->dns_skad, req->dns_skadlen) != req->qaaaalen)) (req->qaaaalen > 0 && sendto (req->dns_socket, req->qaaaa, req->qaaaalen, 0, (struct sockaddr*)&req->dns_skad, req->dns_skadlen) != req->qaaaalen))
{ {
qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
if (httpd->errnum != QSE_HTTPD_EAGAIN || req->dns_retries <= 0) goto oops; /* Unix datagram socket seems to fail with EAGAIN often
/*goto oops;*/ * even with increased SO_SNDBUF size. */
if (httpd->errnum == QSE_HTTPD_EAGAIN && req->dns_retries > 0)
{
/* TODO: check writability of req->urs_socket instead of just retrying... */
goto send_ok;
} }
goto oops;
}
send_ok:
/* NOTE: /* NOTE:
* if the sequence number is repeated before it timed out or resolved, * if the sequence number is repeated before it timed out or resolved,
* the newer request gets chained together with the older one. * the newer request gets chained together with the older one.

View File

@ -382,9 +382,19 @@ static void tmr_urs_tmout_handle (qse_tmr_t* tmr, const qse_ntime_t* now, void*
if (sendto (req->urs_socket, req->pkt, req->pktlen, 0, (struct sockaddr*)&req->urs_skad, req->urs_skadlen) != req->pktlen) if (sendto (req->urs_socket, req->pkt, req->pktlen, 0, (struct sockaddr*)&req->urs_skad, req->urs_skadlen) != req->pktlen)
{ {
/* error. fall thru */ /* error. fall thru */
qse_httpd_seterrnum (dc->httpd, SKERR_TO_ERRNUM());
/* Unix datagram socket seems to fail with EAGAIN often
* even with increased SO_SNDBUF size. */
if (dc->httpd->errnum == QSE_HTTPD_EAGAIN && req->urs_retries > 1)
{
/* TODO: check writability of req->urs_socket instead of just retrying... */
goto send_ok;
}
} }
else else
{ {
send_ok:
QSE_ASSERT (tmr == dc->httpd->tmr); QSE_ASSERT (tmr == dc->httpd->tmr);
if (qse_httpd_inserttimerevent (dc->httpd, &tmout_event, &req->tmr_tmout) >= 0) if (qse_httpd_inserttimerevent (dc->httpd, &tmout_event, &req->tmr_tmout) >= 0)
{ {
@ -533,12 +543,18 @@ static int urs_send (qse_httpd_t* httpd, qse_httpd_urs_t* urs, const qse_mchar_t
qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM()); qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
printf ("URS SENDTO FAILURE........................\n"); /* TODO: logging */ printf ("URS SENDTO FAILURE........................\n"); /* TODO: logging */
/* it looks like the EAGAIN is frequently seen on a unix datagram socket /* Unix datagram socket seems to fail with EAGAIN often
* even with increased SO_SNDBUF size. */ * even with increased SO_SNDBUF size. */
if (httpd->errnum != QSE_HTTPD_EAGAIN || req->urs_retries <= 0) goto oops; if (httpd->errnum == QSE_HTTPD_EAGAIN && req->urs_retries > 0)
/* goto oops; */ {
/* TODO: check writability of req->urs_socket instead of just retrying... */
goto send_ok;
} }
goto oops;
}
send_ok:
req->dc = dc; req->dc = dc;
/* link the request to the front of the chain */ /* link the request to the front of the chain */
@ -548,7 +564,6 @@ printf ("URS SENDTO FAILURE........................\n"); /* TODO: logging */
/* increment the number of pending requests */ /* increment the number of pending requests */
dc->req_count++; dc->req_count++;
return 0; return 0;
oops: oops: