static void qmqpd_reply(QMQPD_STATE *state, int log_message, int status_code, const char *fmt,...) { va_list ap; /* * Optionally change hard errors into retryable ones. Send the reply and * optionally log it. Always insert a delay before reporting a problem. * This slows down software run-away conditions. */ if (status_code == QMQPD_STAT_HARD && var_soft_bounce) status_code = QMQPD_STAT_RETRY; VSTRING_RESET(state->buf); VSTRING_ADDCH(state->buf, status_code); va_start(ap, fmt); vstring_vsprintf_append(state->buf, fmt, ap); va_end(ap); NETSTRING_PUT_BUF(state->client, state->buf); if (log_message) (status_code == QMQPD_STAT_OK ? msg_info : msg_warn) ("%s: %s: %s", state->queue_id, state->namaddr, STR(state->buf) + 1); if (status_code != QMQPD_STAT_OK) sleep(var_qmqpd_err_sleep); netstring_fflush(state->client); }
static void send_data(SESSION *session) { int fd = vstream_fileno(session->stream); int except; /* * Prepare for disaster. */ if ((except = vstream_setjmp(session->stream)) != 0) msg_fatal("%s while sending message", exception_text(except)); /* * Send the message content, by wrapping three netstrings into an * over-all netstring. * * XXX This should be done more carefully to avoid blocking when sending * large messages over slow networks. */ netstring_put_multi(session->stream, STR(message_buffer), LEN(message_buffer), STR(sender_buffer), LEN(sender_buffer), STR(recipient_buffer), LEN(recipient_buffer), (char *) 0); netstring_fflush(session->stream); /* * Wake me up when the server replies or when something bad happens. */ event_enable_read(fd, receive_reply, (char *) session); }
static void send_reply(SINK_STATE *state) { vstring_sprintf(buffer, "%c*k", QMQP_STAT_OK); NETSTRING_PUT_BUF(state->stream, buffer); netstring_fflush(state->stream); if (count_deliveries) { counter++; vstream_printf("%d\r", counter); vstream_fflush(VSTREAM_OUT); } disconnect(state); }