Exemplo n.º 1
0
/*
    Test if the http service (including MPR) is idle with no running requests
 */
static bool isIdle(bool traceRequests)
{
    HttpConn        *conn;
    Http            *http;
    MprTicks        now;
    int             next;
    static MprTicks lastTrace = 0;

    if ((http = MPR->httpService) != 0) {
        now = http->now;
        lock(http->connections);
        for (next = 0; (conn = mprGetNextItem(http->connections, &next)) != 0; ) {
            if (conn->state != HTTP_STATE_BEGIN && conn->state != HTTP_STATE_COMPLETE) {
                if (traceRequests && lastTrace < now) {
                    if (conn->rx) {
                        mprLog("info http", 2, "Request for \"%s\" is still active", 
                            conn->rx->uri ? conn->rx->uri : conn->rx->pathInfo);
                    }
                    lastTrace = now;
                }
                unlock(http->connections);
                return 0;
            }
        }
        unlock(http->connections);
    } else {
        now = mprGetTicks();
    }
    return mprServicesAreIdle(traceRequests);
}
Exemplo n.º 2
0
static bool appwebIsIdle(MprCtx ctx)
{
    MaHost      *host;
    MaConn      *conn;
    MaHttp      *http;
    MprTime     now;
    int         nextHost, next;
    static MprTime lastTrace = 0;

    now = mprGetTime(ctx);
    http = (MaHttp*) mprGetMpr(ctx)->appwebHttpService;
    for (nextHost = 0; (host = mprGetNextItem(http->defaultServer->hosts, &nextHost)) != 0; ) {
        lock(host);
        for (next = 0; (conn = mprGetNextItem(host->connections, &next)) != 0; ) {
            if (conn->state != MPR_HTTP_STATE_BEGIN) {
                if (lastTrace < now) {
                    mprLog(ctx, 0, "Waiting for request %s to complete", 
                           *conn->request->url ? conn->request->url : conn->request->pathInfo);
                    lastTrace = now;
                }
                unlock(host);
                return 0;
            }
        }
        unlock(host);
    }
    if (!mprServicesAreIdle(ctx)) {
        if (lastTrace < now) {
            mprLog(ctx, 0, "Waiting for MPR services complete");
            lastTrace = now;
        }
        return 0;
    }
    return 1;
}