void Connection_abort(Connection *connection, const char *format, ...) { if(CS_ABORTED == connection->state) { return; } //abort batch char error1[MAX_ERROR_SIZE]; char error2[MAX_ERROR_SIZE]; va_list args; va_start(args, format); vsnprintf(error1, MAX_ERROR_SIZE, format, args); va_end(args); snprintf(error2, MAX_ERROR_SIZE, "Connection error %s [addr: %s:%s]", error1, connection->addr, connection->serv); DEBUG(("Connection aborting: %s\n", error2)); Batch_abort(connection->current_batch, error2); connection->current_batch = NULL; connection->current_executor = NULL; Connection_close(connection); connection->state = CS_ABORTED; DEBUG(("Connection aborted\n")); }
void Connection_abort(Connection *connection, const char *format, ...) { if(CS_ABORTED == connection->state) { return; } //abort batch char error1[MAX_ERROR_SIZE]; char error2[MAX_ERROR_SIZE]; va_list args; va_start(args, format); vsnprintf(error1, MAX_ERROR_SIZE, format, args); va_end(args); snprintf(error2, MAX_ERROR_SIZE, "Connection error %s [addr: %s]", error1, connection->addr); DEBUG(("Connection aborting: %s\n", error2)); Batch_abort(connection->current_batch, error2); connection->current_batch = NULL; connection->current_executor = NULL; if(CS_CONNECTED == connection->state || CS_CONNECTING == connection->state) { assert(connection->sockfd > 0); //close the socket close(connection->sockfd); } connection->sockfd = 0; connection->state = CS_ABORTED; DEBUG(("Connection aborted\n")); }