src/raw_sock.c
static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int flags)
{
	int ret, try, done, send_flag;

	done = 0;
	/* send the largest possible block. For this we perform only one call
	 * to send() unless the buffer wraps and we exactly fill the first hunk,
	 * in which case we accept to do it once again.
	 */
	while (buf->o) {
		try = buf->o;
		/* outgoing data may wrap at the end */
		if (buf->data + try > buf->p)
			try = buf->data + try - buf->p;

		send_flag = MSG_DONTWAIT | MSG_NOSIGNAL;
		if (try < buf->o)
			send_flag = MSG_MORE;

		ret = send(conn->t.sock.fd, bo_ptr(buf), try, send_flag | flags);

		if (ret > 0) {
			buf->o -= ret;
			done += ret;

			if (likely(buffer_empty(buf)))
				/* optimize data alignment in the buffer */
				buf->p = buf->data;

			/* if the system buffer is full, don't insist */
			if (ret < try)
				break;
		}
		else if (ret == 0 || errno == EAGAIN || errno == ENOTCONN) {
			/* nothing written, we need to poll for write first */
			__conn_data_poll_send(conn);
			break;
		}
		else if (errno != EINTR) {
			conn->flags |= CO_FL_ERROR;
			break;
		}
	}
	if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
		conn->flags &= ~CO_FL_WAIT_L4_CONN;
	return done;
}
/* Send all pending bytes from buffer <buf> to connection <conn>'s socket.
 * <flags> may contain MSG_MORE to make the system hold on without sending
 * data too fast.
 * Only one call to send() is performed, unless the buffer wraps, in which case
 * a second call may be performed. The connection's flags are updated with
 * whatever special event is detected (error, empty). The caller is responsible
 * for taking care of those events and avoiding the call if inappropriate. The
 * function does not call the connection's polling update function, so the caller
 * is responsible for this.
 */
Send all pending bytes from buffer  to connection 's socket.
 may contain MSG_MORE to make the system hold on without sending
data too fast.
Only one call to send() is performed, unless the buffer wraps, in which case
a second call may be performed. The connection's flags are updated with
whatever special event is detected (error, empty). The caller is responsible
for taking care of those events and avoiding the call if inappropriate. The
function does not call the connection's polling update function, so the caller
is responsible for this.
Send all pending bytes from buffer to connection ' s socket . may contain MSG_MORE to make the system hold on without sending data too fast . Only one call to send () is performed unless the buffer wraps in which case a second call may be performed . The connection ' s flags are updated with whatever special event is detected ( error empty ) . The caller is responsible for taking care of those events and avoiding the call if inappropriate . The function does not call the connection ' s polling update function so the caller is responsible for this .
static int raw_sock_from_buf(struct connection *conn, struct buffer *buf, int flags)
{
	int ret, try, done, send_flag;
	done = 0;
	while (buf->o) {
		try = buf->o;
		if (buf->data + try > buf->p)
			try = buf->data + try - buf->p;
		send_flag = MSG_DONTWAIT | MSG_NOSIGNAL;
		if (try < buf->o)
			send_flag = MSG_MORE;
		ret = send(conn->t.sock.fd, bo_ptr(buf), try, send_flag | flags);
		if (ret > 0) {
			buf->o -= ret;
			done += ret;
			if (likely(buffer_empty(buf)))
				buf->p = buf->data;
			if (ret < try)
				break;
		}
		else if (ret == 0 || errno == EAGAIN || errno == ENOTCONN) {
			__conn_data_poll_send(conn);
			break;
		}
		else if (errno != EINTR) {
			conn->flags |= CO_FL_ERROR;
			break;
		}
	}
	if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
		conn->flags &= ~CO_FL_WAIT_L4_CONN;
	return done;
}
static int raw_sock_from_buf ( struct connection * conn , struct buffer * buf , int flags ) { int ret , try , done , send_flag ; done = 0 ; while ( buf -> o ) { try = buf -> o ; if ( buf -> data + try > buf -> p ) try = buf -> data + try - buf -> p ; send_flag = MSG_DONTWAIT | MSG_NOSIGNAL ; if ( try < buf -> o ) send_flag = MSG_MORE ; ret = send ( conn -> t . sock . fd , bo_ptr ( buf ) , try , send_flag | flags ) ; if ( ret > 0 ) { buf -> o -= ret ; done += ret ; if ( likely ( buffer_empty ( buf ) ) ) buf -> p = buf -> data ; if ( ret < try ) break ; } else if ( ret == 0 || errno == EAGAIN || errno == ENOTCONN ) { __conn_data_poll_send ( conn ) ; break ; } else if ( errno != EINTR ) { conn -> flags |= CO_FL_ERROR ; break ; } } if ( unlikely ( conn -> flags & CO_FL_WAIT_L4_CONN ) && done ) conn -> flags &= ~ CO_FL_WAIT_L4_CONN ; return done ; }
Send all pending bytes from buffer <buf> to connection <conn>'s socket.
Send all pending bytes from buffer <buf > to connection <conn > ' s socket .
/* send the largest possible block. For this we perform only one call
	 * to send() unless the buffer wraps and we exactly fill the first hunk,
	 * in which case we accept to do it once again.
	 */ /* outgoing data may wrap at the end */ /* optimize data alignment in the buffer */ /* if the system buffer is full, don't insist */ /* nothing written, we need to poll for write first */