Non-idempotent retry in ne_begin_request()

Thomas F 4xchu0ouxc33vxi at jetable.net
Sun Jan 3 20:02:02 EST 2010


Hi,

I wonder whether ne_begin_request() does the right thing for
non-idempotent requests: the first send_request() attempt
can only fail due to server failure (because the connection
is freshly opened), but is retried nevertheless.

Shouldn't the retry be suppressed in the non-idempotent case?

int ne_begin_request(ne_request *req)
{

[...]

    /* If a non-idempotent request is sent on a persisted connection,
     * then it is impossible to distinguish between a server failure
     * and a connection timeout if an EOF/RST is received.  So don't
     * do that. */
    if (!req->flags[NE_REQFLAG_IDEMPOTENT] && req->session->persisted
        && !req->session->flags[NE_SESSFLAG_CONNAUTH]) {
        NE_DEBUG(NE_DBG_HTTP, "req: Closing connection for non-idempotent "
                 "request.\n");
        ne_close_connection(req->session);
    }

    /* Build the request string, and send it */
    data = build_request(req);
    DEBUG_DUMP_REQUEST(data->data);
    ret = send_request(req, data);
    /* Retry this once after a persistent connection timeout. */
    if (ret == NE_RETRY) {
        NE_DEBUG(NE_DBG_HTTP, "Persistent connection timed out,
retrying.\n");
        ret = send_request(req, data);
    }
    ne_buffer_destroy(data);

[...]

Disclaimer: I didn't test this, I just read the code, so I could
be completely wrong...

Best regards,
Thomas




More information about the neon mailing list