Ejemplo n.º 1
0
int
ts_http_fetcher_callback_sm(http_fetcher *fch, TSEvent event)
{
    if (fch->deleted && !fch->ref) {
        ts_http_fetcher_release(fch);
        return -1;
    }

    if (event == TS_FETCH_EVENT_BODY_QUIET)
        return 0;

    fch->ref++;

    if (fch->flags & TS_FETCH_FLAG_USE_NEW_LOCK)
        TSMutexLock(TSContMutexGet(fch->contp));

    TSContCall(fch->contp, event, fch);

    if (fch->flags & TS_FETCH_FLAG_USE_NEW_LOCK)
        TSMutexUnlock(TSContMutexGet(fch->contp));

    fch->ref--;

    if (fch->deleted && !fch->ref) {
        ts_http_fetcher_release(fch);
        return -1;
    }

    return 0;
}
Ejemplo n.º 2
0
int
ts_http_fetcher_callback_sm(http_fetcher *fch, TSEvent event)
{
    if (fch->deleted && !fch->ref) {
        ts_http_fetcher_release(fch);
        return -1;
    }

    if (event == TS_EVENT_FETCH_BODY_QUIET || fch->stopped) {
        return 0;

    } else if (event != TS_EVENT_FETCH_HEADER_DONE &&
               event != TS_EVENT_FETCH_BODY_READY &&
               event != TS_EVENT_FETCH_BODY_QUIET) {

        fch->stopped = 1;
    }

    fch->ref++;

    if (fch->flags & TS_FLAG_FETCH_USE_NEW_LOCK)
        TSMutexLock(TSContMutexGet(fch->contp));

    TSContCall(fch->contp, event, fch);

    if (fch->flags & TS_FLAG_FETCH_USE_NEW_LOCK)
        TSMutexUnlock(TSContMutexGet(fch->contp));

    fch->ref--;

    if (fch->deleted && !fch->ref) {
        ts_http_fetcher_release(fch);
        return -1;
    }

    return 0;
}
Ejemplo n.º 3
0
void
ts_http_fetcher_destroy(http_fetcher *fch)
{
    if (fch->action) {
        TSActionCancel(fch->action);
        fch->action = NULL;
    }

    fch->deleted = 1;

    if (fch->ref)
        return;

    ts_http_fetcher_release(fch);
}