Esempio n. 1
0
/*
    Write data back to the client (browser). Must be locked when called.
 */
static int writeToClient(MaQueue *q, MprCmd *cmd, MprBuf *buf, int channel)
{
    MaConn  *conn;
    int     rc, len;

    conn = q->conn;

    /*
        Write to the browser. We write as much as we can. Service queues to get the filters and connectors pumping.
     */
    while ((len = mprGetBufLength(buf)) > 0) {
        if (!conn->requestFailed) {
            rc = maWriteBlock(q, mprGetBufStart(buf), len, 1);
            mprLog(q, 5, "CGI: write %d bytes to client. Rc rc %d, errno %d", len, rc, mprGetOsError());
        } else {
            /* Request has failed so just eat the data */
            rc = len;
            mprAssert(len > 0);
        }
        if (rc < 0) {
            return MPR_ERR_CANT_WRITE;
        }
        mprAssert(rc == len);
        mprAdjustBufStart(buf, rc);
        mprResetBufIfEmpty(buf);
        maServiceQueues(conn);
    }
    return 0;
}
Esempio n. 2
0
static int writeBlock(void *handle, cchar *buf, int size)
{
    MaConn      *conn;
    MaQueue     *q;

    conn = (MaConn*) handle;

    /*
     *  We write to the service queue of the handler
     */
    q = conn->response->queue[MA_QUEUE_SEND].nextQ;
    mprAssert(q->stage->flags & MA_STAGE_HANDLER);

    return maWriteBlock(q, buf, size, 1);
}
Esempio n. 3
0
static int writeBlock(cchar *str, uint len TSRMLS_DC)
{
    MaConn      *conn;
    int         written;

    conn = (MaConn*) SG(server_context);
    if (conn == 0) {
        return -1;
    }
    written = maWriteBlock(conn->response->queue[MA_QUEUE_SEND].nextQ, str, len, 1);
    mprLog(mprGetMpr(0), 6, "php: write %d", written);
    if (written <= 0) {
        php_handle_aborted_connection();
    }
    return written;
}
Esempio n. 4
0
int maWriteString(MaQueue *q, cchar *s)
{
    return maWriteBlock(q, s, (int) strlen(s), 1);
}