Esempio n. 1
0
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);
    }
}
Esempio n. 2
0
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);
    }
}
Esempio n. 3
0
static void
rtpp_notify_queue_run(void *arg)
{
    struct rtpp_wi *wi;
    struct rtpp_notify_wi *wi_data;
    struct rtpp_notify_priv *pvt;

    pvt = (struct rtpp_notify_priv *)arg;
    for (;;) {
        wi = rtpp_queue_get_item(pvt->nqueue, 0);
        if (rtpp_wi_get_type(wi) == RTPP_WI_TYPE_SGNL) {
            rtpp_wi_free(wi);
            break;
        }
        wi_data = rtpp_wi_data_get_ptr(wi, sizeof(struct rtpp_notify_wi), 0);

        /* main work here */
        do_timeout_notification(wi_data, 3, wi->log);

        /* deallocate wi */
        rtpp_wi_free(wi);
    }
}