2
Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; version 2 of the
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24
#include "network-injection.h"
26
#include "network-mysqld-proto.h"
27
#include "network-mysqld-packet.h"
30
#include "chassis-timings.h"
32
#define C(x) x, sizeof(x) - 1
33
#define S(x) x->str, x->len
35
#define TIME_DIFF_US(t2, t1) \
36
((t2.tv_sec - t1.tv_sec) * 1000000.0 + (t2.tv_usec - t1.tv_usec))
40
* Initialize an injection struct.
42
injection *injection_new(int id, GString *query) {
45
i = g_new0(injection, 1);
48
i->resultset_is_needed = FALSE; /* don't buffer the resultset */
51
* we have to assume that injection_new() is only used by the read_query call
52
* which should be fine
54
i->ts_read_query = chassis_get_rel_microseconds();
55
/* g_get_current_time(&(i->ts_read_query)); */
61
* Free an injection struct
63
void injection_free(injection *i) {
66
if (i->query) g_string_free(i->query, TRUE);
71
network_injection_queue *network_injection_queue_new() {
75
void network_injection_queue_free(network_injection_queue *q) {
78
network_injection_queue_reset(q);
83
void network_injection_queue_reset(network_injection_queue *q) {
87
while ((inj = g_queue_pop_head(q))) injection_free(inj);
90
void network_injection_queue_append(network_injection_queue *q, injection *inj) {
91
g_queue_push_tail(q, inj);
94
void network_injection_queue_prepend(network_injection_queue *q, injection *inj) {
95
g_queue_push_head(q, inj);
98
guint network_injection_queue_len(network_injection_queue *q) {
102
* Initialize a resultset struct
104
proxy_resultset_t *proxy_resultset_init() {
105
return proxy_resultset_new();
108
proxy_resultset_t *proxy_resultset_new() {
109
proxy_resultset_t *res;
111
res = g_new0(proxy_resultset_t, 1);
117
* Free a resultset struct
119
void proxy_resultset_free(proxy_resultset_t *res) {
123
network_mysqld_proto_fielddefs_free(res->fields);