root/platform/mysql/mycached/trunk/mycached_as_udf.cc @ 35019

Revision 35019, 1.9 kB (checked in by kazuho, 4 years ago)

update picoev

Line 
1/*
2 * mycached - memcached protocol handler for mysqld
3 *
4 * Copyright (C) 2009 Cybozu Labs, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the FreeSoftware
8 * Foundation; either version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include "mycached.hh"
21#include "mycached.cc"
22extern "C" {
23#ifdef MYCACHED_USE_SELECT
24# include "picoev_select.c"
25#elif defined(MYCACHED_USE_KQUEUE)
26# include "picoev_kqueue.c"
27#elif defined(MYCACHED_USE_EPOLL)
28# include "picoev_epoll.c"
29#else
30# error "define one of: MYCACHED_USE_SELECT, MYCACHED_USE_KQUEUE, MYCACHED_USE_EPOLL"
31#endif
32}
33
34#define SETUP_ARG(i, t, n) \
35  do { \
36    args->arg_type[i] = t; \
37    args->maybe_null[i] = n; \
38  } while (0)
39#define SETUP_ARG_IF(i, t, n) \
40  do { \
41    if (i < args->arg_count) \
42      SETUP_ARG(i, t, n); \
43  } while (0)
44
45extern "C"
46my_bool
47mycached_start_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
48{
49  if (args->arg_count != 2) {
50    strcpy(message, "mycached_start(host,port): invalid arguments");
51    return 1;
52  }
53  initid->maybe_null = 0;
54  SETUP_ARG(0, INT_RESULT, 0);
55  SETUP_ARG(1, INT_RESULT, 0);
56  return 0;
57}
58
59extern "C"
60void
61mycached_start_deinit(UDF_INIT* initid)
62{
63}
64
65extern "C"
66long long
67mycached_start(UDF_INIT* initid, UDF_ARGS* args, char* is_null, char* error)
68{
69  return mycached::conn_t::start_server(*(long long*)args->args[0],
70                                        *(long long*)args->args[1]);
71}
Note: See TracBrowser for help on using the browser.