/* * Helper functions to send data over a socket and buffer. * Should probably move somewhere else, but where ? * * Copyright 2000-2008 Willy Tarreau * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * returns a message to the client ; the connection is shut down for read, * and the request is cleared so that no server connection can be initiated. * The client must be in a valid state for this (HEADER, DATA ...). * Nothing is performed on the server side. The message is contained in a * "chunk". If it is null, then an empty message is used. * The reply buffer doesn't need to be empty before this. */ void client_retnclose(struct session *s, const struct chunk *msg) { //FIXME: must move to lower level //EV_FD_CLR(s->cli_fd, DIR_RD); //EV_FD_SET(s->cli_fd, DIR_WR); buffer_abort(s->req); s->cli_state = CL_STSHUTR; // FIXME: still used by unix sockets buffer_flush(s->rep); buffer_shutr_now(s->rep); if (msg && msg->len) buffer_write(s->rep, msg->str, msg->len); s->rep->wex = tick_add_ifset(now_ms, s->rep->wto); buffer_write_ena(s->rep); } /* * returns a message into the rep buffer, and flushes the req buffer. * The reply buffer doesn't need to be empty before this. The message * is contained in a "chunk". If it is null, then an empty message is * used. */ void client_return(struct session *s, const struct chunk *msg) { buffer_flush(s->req); buffer_flush(s->rep); if (msg && msg->len) buffer_write(s->rep, msg->str, msg->len); } /* * Local variables: * c-indent-level: 8 * c-basic-offset: 8 * End: */