static void do_timeout_notification(struct rtpp_notify_wi *wi, int retries, struct rtpp_log *log) { int result; if (wi->rttp->connected == 0) { reconnect_timeout_handler(log, wi->rttp); /* If connect fails, no notification will be sent */ if (wi->rttp->connected == 0) { RTPP_LOG(log, RTPP_LOG_ERR, "unable to send timeout notification"); return; } } do { result = send(wi->rttp->fd, wi->notify_buf, wi->len - 1, 0); } while (result == -1 && errno == EINTR); if (result < 0) { wi->rttp->connected = 0; RTPP_ELOG(log, RTPP_LOG_ERR, "failed to send timeout notification"); if (retries > 0) do_timeout_notification(wi, retries - 1, log); } }
void do_timeout_notification(struct rtpp_session *sp, int retries) { int result, len; struct rtpp_timeout_handler *th = sp->timeout_data.handler; if (th == NULL) return; if (th->connected == 0) { reconnect_timeout_handler(sp, th); /* If connect fails, no notification will be sent */ if (th->connected == 0) { rtpp_log_write(RTPP_LOG_ERR, sp->log, "unable to send timeout notification"); return; } } if (sp->timeout_data.notify_tag == NULL) { len = snprintf(th->notify_buf, sizeof(th->notify_buf), "%d %d\n", sp->ports[0], sp->ports[1]); } else { len = snprintf(th->notify_buf, sizeof(th->notify_buf), "%s\n", sp->timeout_data.notify_tag); } assert(len < (int)sizeof(th->notify_buf)); do { result = send(th->fd, th->notify_buf, len, 0); } while (len == -1 && errno == EINTR); if (result < 0) { th->connected = 0; rtpp_log_ewrite(RTPP_LOG_ERR, sp->log, "failed to send timeout notification"); if (retries > 0) do_timeout_notification(sp, retries - 1); } }