root/src/modules/lua_noit.h

Revision a719cb681d36678e18a208f35dc8058c4beb1e32, 3.5 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 4 years ago)

fix copyright

  • Property mode set to 100644
Line 
1 /*
2  * Copyright (c) 2007-2010, OmniTI Computer Consulting, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *     * Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *     * Redistributions in binary form must reproduce the above
12  *       copyright notice, this list of conditions and the following
13  *       disclaimer in the documentation and/or other materials provided
14  *       with the distribution.
15  *     * Neither the name OmniTI Computer Consulting, Inc. nor the names
16  *       of its contributors may be used to endorse or promote products
17  *       derived from this software without specific prior written
18  *       permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef LUA_NOIT_H
34 #define LUA_NOIT_H
35
36 #include "noit_defines.h"
37
38 #include "noit_conf.h"
39 #include "noit_module.h"
40 #include "noit_check.h"
41 #include "noit_check_tools.h"
42 #include "utils/noit_log.h"
43
44 #include <assert.h>
45
46 #include "lua.h"
47 #include "lauxlib.h"
48 #include "lualib.h"
49
50 typedef struct lua_module_closure {
51   char *object;
52   lua_State *lua_state;
53   int object_ref;
54 } lua_module_closure_t;
55
56 typedef struct noit_lua_check_info {
57   noit_module_t *self;
58   noit_check_t *check;
59   int timed_out;
60   eventer_t timeout_event;
61   lua_module_closure_t *lmc;
62   lua_State *coro_state;
63   int coro_state_ref;
64   struct timeval finish_time;
65   stats_t current;
66   noit_hash_table *events; /* Any eventers we need to cleanup */
67 } noit_lua_check_info_t;
68
69 struct nl_generic_cl {
70   void (*free)(void *);
71 };
72
73 struct nl_intcl {
74   void (*free)(void *);
75   noit_lua_check_info_t *ci;
76 };
77
78 struct nl_slcl {
79   void (*free)(void *);
80   int send_size;
81   struct timeval start;
82   char *inbuff;
83   int   inbuff_allocd;
84   int   inbuff_len;
85   size_t read_sofar;
86   size_t read_goal;
87   const char *read_terminator;
88   const char *outbuff;
89   size_t write_sofar;
90   size_t write_goal;
91   eventer_t *eptr;
92
93   int sendto; /* whether this send is a sendto call */
94   union {
95     struct sockaddr_in sin4;
96     struct sockaddr_in6 sin6;
97   } address;
98
99   lua_State *L;
100 };
101
102 void noit_lua_init();
103 void noit_lua_init_dns();
104 int noit_lua_dns_gc(lua_State *L);
105 int noit_lua_dns_index_func(lua_State *L);
106 int nl_dns_lookup(lua_State *L);
107 int luaopen_noit(lua_State *L);
108 int luaopen_pack(lua_State *L); /* from lua_lpack.c */
109 noit_lua_check_info_t *get_ci(lua_State *L);
110 int noit_lua_yield(noit_lua_check_info_t *ci, int nargs);
111 int noit_lua_resume(noit_lua_check_info_t *ci, int nargs);
112 void noit_lua_check_register_event(noit_lua_check_info_t *ci, eventer_t e);
113 void noit_lua_check_deregister_event(noit_lua_check_info_t *ci, eventer_t e,
114                                      int tofree);
115
116 #endif
Note: See TracBrowser for help on using the browser.