~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/drizzle_protocol/drizzle_protocol.cc

  • Committer: Lee Bieber
  • Date: 2010-12-15 16:23:36 UTC
  • mfrom: (1995.1.2 build)
  • Revision ID: kalebral@gmail.com-20101215162336-juntyt4gw4vgohg4
Merge Andrew - fix bug 628912: Crash / segfault in drizzled::Item_func::arguments (this=0x35) at ./drizzled/function/func.h
Merge Andrew - 663919: next query after KILL QUERY will error

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <drizzled/gettext.h>
24
24
#include <drizzled/error.h>
25
25
#include <drizzled/query_id.h>
 
26
#include <drizzled/sql_state.h>
26
27
#include <drizzled/session.h>
27
28
#include "drizzled/internal/my_sys.h"
28
29
#include "drizzled/internal/m_string.h"
30
31
#include <iostream>
31
32
#include <boost/program_options.hpp>
32
33
#include <drizzled/module/option_map.h>
33
 
#include "drizzled/util/tokenize.h"
34
34
#include "drizzle_protocol.h"
 
35
#include "plugin/drizzle_protocol/status_table.h"
35
36
 
36
37
namespace po= boost::program_options;
37
38
using namespace drizzled;
42
43
namespace drizzle_protocol
43
44
{
44
45
 
45
 
std::vector<std::string> ClientDrizzleProtocol::drizzle_admin_ip_addresses;
 
46
 
46
47
static port_constraint port;
47
48
static timeout_constraint connect_timeout;
48
49
static timeout_constraint read_timeout;
63
64
  return port;
64
65
}
65
66
 
66
 
void ClientDrizzleProtocol::drizzle_compose_ip_addresses(vector<string> options)
67
 
{
68
 
  for (vector<string>::iterator it= options.begin();
69
 
       it != options.end();
70
 
       ++it)
71
 
  {
72
 
    tokenize(*it, drizzle_admin_ip_addresses, ",", true);
73
 
  }
74
 
}
75
 
 
76
 
bool ClientDrizzleProtocol::isAdminAllowed(void)
77
 
{
78
 
  if (std::find(drizzle_admin_ip_addresses.begin(), drizzle_admin_ip_addresses.end(), session->user()->address()) != drizzle_admin_ip_addresses.end())
79
 
    return true;
80
 
 
81
 
  return false;
82
 
}
83
 
 
84
 
plugin::Client *ListenDrizzleProtocol::getClient(int fd)
85
 
{
86
 
  int new_fd;
87
 
  new_fd= acceptTcp(fd);
88
 
  if (new_fd == -1)
89
 
    return NULL;
90
 
 
91
 
  return new ClientDrizzleProtocol(new_fd, getCounters());
92
 
}
93
 
 
94
67
static int init(drizzled::module::Context &context)
95
68
{  
96
69
  const module::option_map &vm= context.getOptions();
97
70
 
98
 
  ListenDrizzleProtocol *protocol=new ListenDrizzleProtocol("drizzle_protocol", vm["bind-address"].as<std::string>(), true);
99
 
  protocol->addCountersToTable();
100
 
  context.add(protocol);
 
71
  context.add(new StatusTable);
 
72
  context.add(new ListenDrizzleProtocol("drizzle_protocol", vm["bind-address"].as<std::string>(), true));
101
73
  context.registerVariable(new sys_var_constrained_value_readonly<in_port_t>("port", port));
102
74
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("connect_timeout", connect_timeout));
103
75
  context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("read_timeout", read_timeout));
139
111
  context("max-connections",
140
112
          po::value<uint32_t>(&ListenDrizzleProtocol::drizzle_counters->max_connections)->default_value(1000),
141
113
          N_("Maximum simultaneous connections."));
142
 
  context("admin-ip-addresses",
143
 
          po::value<vector<string> >()->composing()->notifier(&ClientDrizzleProtocol::drizzle_compose_ip_addresses),
144
 
          N_("A restrictive IP address list for incoming admin connections."));
145
114
}
146
115
 
147
116
} /* namespace drizzle_protocol */