root/src/modules/lua_noit.h

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

propagate the cause for causal checks into all of the calls

  • 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   noit_check_t *cause;
60   int timed_out;
61   eventer_t timeout_event;
62   lua_module_closure_t *lmc;
63   lua_State *coro_state;
64   int coro_state_ref;
65   struct timeval finish_time;
66   stats_t current;
67   noit_hash_table *events; /* Any eventers we need to cleanup */
68 } noit_lua_check_info_t;
69
70 struct nl_generic_cl {
71   void (*free)(void *);
72 };
73
74 struct nl_intcl {
75   void (*free)(void *);
76   noit_lua_check_info_t *ci;
77 };
78
79 struct nl_slcl {
80   void (*free)(void *);
81   int send_size;
82   struct timeval start;
83   char *inbuff;
84   int   inbuff_allocd;
85   int   inbuff_len;
86   size_t read_sofar;
87   size_t read_goal;
88   const char *read_terminator;
89   const char *outbuff;
90   size_t write_sofar;
91   size_t write_goal;
92   eventer_t *eptr;
93
94   int sendto; /* whether this send is a sendto call */
95   union {
96     struct sockaddr_in sin4;
97     struct sockaddr_in6 sin6;
98   } address;
99
100   lua_State *L;
101 };
102
103 void noit_lua_init();
104 void noit_lua_init_dns();
105 int noit_lua_dns_gc(lua_State *L);
106 int noit_lua_dns_index_func(lua_State *L);
107 int nl_dns_lookup(lua_State *L);
108 int luaopen_noit(lua_State *L);
109 int luaopen_pack(lua_State *L); /* from lua_lpack.c */
110 noit_lua_check_info_t *get_ci(lua_State *L);
111 int noit_lua_yield(noit_lua_check_info_t *ci, int nargs);
112 int noit_lua_resume(noit_lua_check_info_t *ci, int nargs);
113 void noit_lua_check_register_event(noit_lua_check_info_t *ci, eventer_t e);
114 void noit_lua_check_deregister_event(noit_lua_check_info_t *ci, eventer_t e,
115                                      int tofree);
116
117 #endif
Note: See TracBrowser for help on using the browser.