Compare commits
6 Commits
b41e02860c
...
54d7b46774
Author | SHA1 | Date | |
---|---|---|---|
54d7b46774 | |||
3bf903c398 | |||
53337c81d4 | |||
5977493f47 | |||
7aec09dd27 | |||
4a4fd8fd11 |
2
COPYING
2
COPYING
@ -32,3 +32,5 @@ From doc/bootstrap* (Apache License 2.0):
|
|||||||
Licensed under http://www.apache.org/licenses/LICENSE-2.0
|
Licensed under http://www.apache.org/licenses/LICENSE-2.0
|
||||||
From doc/jquery-1.10.1.min.js (MIT License):
|
From doc/jquery-1.10.1.min.js (MIT License):
|
||||||
(c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
|
(c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
|
||||||
|
|
||||||
|
Also include/lighttpd/hedley.h is licensed as CC0-1.0 by Evan Nemerson.
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <lighttpd/base.h>
|
#include <lighttpd/base.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
|
||||||
|
LI_API void li_lua_init_action_mt(liServer *srv, lua_State *L);
|
||||||
|
|
||||||
LI_API liAction* li_lua_get_action(lua_State *L, int ndx);
|
LI_API liAction* li_lua_get_action(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_action(liServer *srv, lua_State *L, liAction *a);
|
LI_API int li_lua_push_action(liServer *srv, lua_State *L, liAction *a);
|
||||||
|
|
||||||
|
@ -72,10 +72,10 @@ struct liLog {
|
|||||||
LI_API void li_log_init(liServer *srv);
|
LI_API void li_log_init(liServer *srv);
|
||||||
LI_API void li_log_clean(liServer *srv);
|
LI_API void li_log_clean(liServer *srv);
|
||||||
|
|
||||||
LI_API void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);
|
LI_API void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) HEDLEY_PRINTF_FORMAT(4, 5);
|
||||||
|
|
||||||
/* replaces '\r' and '\n' with '\0' */
|
/* replaces '\r' and '\n' with '\0' */
|
||||||
LI_API void li_log_split_lines(liServer *srv, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
|
LI_API void li_log_split_lines(liServer *srv, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
|
||||||
LI_API void li_log_split_lines_(liServer *srv, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) G_GNUC_PRINTF(5, 6);
|
LI_API void li_log_split_lines_(liServer *srv, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) HEDLEY_PRINTF_FORMAT(5, 6);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <lighttpd/base.h>
|
#include <lighttpd/base.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
|
||||||
|
LI_API void li_lua_init_condition_mt(liServer *srv, lua_State *L);
|
||||||
|
|
||||||
LI_API liCondition* li_lua_get_condition(lua_State *L, int ndx);
|
LI_API liCondition* li_lua_get_condition(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_condition(liServer *srv, lua_State *L, liCondition *c);
|
LI_API int li_lua_push_condition(liServer *srv, lua_State *L, liCondition *c);
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
#define _LIGHTTPD_CONFIG_LUA_H_
|
#define _LIGHTTPD_CONFIG_LUA_H_
|
||||||
|
|
||||||
#include <lighttpd/base.h>
|
#include <lighttpd/base.h>
|
||||||
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
|
||||||
|
|
||||||
LI_API gboolean li_config_lua_load(liLuaState *LL, liServer *srv, liWorker *wrk, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args);
|
LI_API gboolean li_config_lua_load(liLuaState *LL, liServer *srv, liWorker *wrk, const gchar *filename, liAction **pact, gboolean allow_setup, liValue *args);
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <lighttpd/base.h>
|
#include <lighttpd/base.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#define LI_LUA_REGISTRY_STATE "lighttpd.state"
|
#define LI_LUA_REGISTRY_STATE "lighttpd.state"
|
||||||
#define LI_LUA_REGISTRY_SERVER "lighttpd.server"
|
#define LI_LUA_REGISTRY_SERVER "lighttpd.server"
|
||||||
@ -14,65 +15,85 @@ LI_API liLuaState *li_lua_state_get(lua_State *L);
|
|||||||
INLINE void li_lua_lock(liLuaState *LL);
|
INLINE void li_lua_lock(liLuaState *LL);
|
||||||
INLINE void li_lua_unlock(liLuaState *LL);
|
INLINE void li_lua_unlock(liLuaState *LL);
|
||||||
|
|
||||||
|
/* expect (meta)table at top of the stack */
|
||||||
|
INLINE void li_lua_protect_metatable(lua_State *L);
|
||||||
|
INLINE int li_lua_new_protected_metatable(lua_State *L, const char *tname);
|
||||||
|
|
||||||
|
/* chunk_lua.c */
|
||||||
LI_API void li_lua_init_chunk_mt(lua_State *L);
|
LI_API void li_lua_init_chunk_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liChunk* li_lua_get_chunk(lua_State *L, int ndx);
|
LI_API liChunk* li_lua_get_chunk(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_chunk(lua_State *L, liChunk *c);
|
LI_API int li_lua_push_chunk(lua_State *L, liChunk *c);
|
||||||
LI_API liChunkQueue* li_lua_get_chunkqueue(lua_State *L, int ndx);
|
LI_API liChunkQueue* li_lua_get_chunkqueue(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_chunkqueue(lua_State *L, liChunkQueue *cq);
|
LI_API int li_lua_push_chunkqueue(lua_State *L, liChunkQueue *cq);
|
||||||
|
|
||||||
LI_API void li_lua_init_connection_mt(lua_State *L);
|
/* environment_lua.c */
|
||||||
LI_API liConnection* li_lua_get_connection(lua_State *L, int ndx);
|
|
||||||
LI_API int li_lua_push_connection(lua_State *L, liConnection *con);
|
|
||||||
|
|
||||||
LI_API void li_lua_init_environment_mt(lua_State *L);
|
LI_API void li_lua_init_environment_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liEnvironment* li_lua_get_environment(lua_State *L, int ndx);
|
LI_API liEnvironment* li_lua_get_environment(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_environment(lua_State *L, liEnvironment *env);
|
LI_API int li_lua_push_environment(lua_State *L, liEnvironment *env);
|
||||||
|
|
||||||
|
/* filters_lua.c */
|
||||||
LI_API void li_lua_init_filter_mt(lua_State *L);
|
LI_API void li_lua_init_filter_mt(lua_State *L);
|
||||||
|
/* create entries in `lighty.` table, which must be on top of the stack */
|
||||||
|
LI_API void li_lua_init_filters(lua_State *L, liServer* srv);
|
||||||
|
|
||||||
LI_API liFilter* li_lua_get_filter(lua_State *L, int ndx);
|
LI_API liFilter* li_lua_get_filter(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_filter(lua_State *L, liFilter *f);
|
LI_API int li_lua_push_filter(lua_State *L, liFilter *f);
|
||||||
LI_API void li_lua_init_filters(lua_State *L, liServer* srv);
|
|
||||||
LI_API liFilter* li_lua_vrequest_add_filter_in(lua_State *L, liVRequest *vr, int state_ndx);
|
LI_API liFilter* li_lua_vrequest_add_filter_in(lua_State *L, liVRequest *vr, int state_ndx);
|
||||||
LI_API liFilter* li_lua_vrequest_add_filter_out(lua_State *L, liVRequest *vr, int state_ndx);
|
LI_API liFilter* li_lua_vrequest_add_filter_out(lua_State *L, liVRequest *vr, int state_ndx);
|
||||||
|
|
||||||
|
/* http_headers_lua.c */
|
||||||
LI_API void li_lua_init_http_headers_mt(lua_State *L);
|
LI_API void li_lua_init_http_headers_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liHttpHeaders* li_lua_get_http_headers(lua_State *L, int ndx);
|
LI_API liHttpHeaders* li_lua_get_http_headers(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_http_headers(lua_State *L, liHttpHeaders *headers);
|
LI_API int li_lua_push_http_headers(lua_State *L, liHttpHeaders *headers);
|
||||||
|
|
||||||
|
/* physical_lua.c */
|
||||||
LI_API void li_lua_init_physical_mt(lua_State *L);
|
LI_API void li_lua_init_physical_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liPhysical* li_lua_get_physical(lua_State *L, int ndx);
|
LI_API liPhysical* li_lua_get_physical(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_physical(lua_State *L, liPhysical *phys);
|
LI_API int li_lua_push_physical(lua_State *L, liPhysical *phys);
|
||||||
|
|
||||||
|
/* request_lua.c */
|
||||||
LI_API void li_lua_init_request_mt(lua_State *L);
|
LI_API void li_lua_init_request_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liRequest* li_lua_get_request(lua_State *L, int ndx);
|
LI_API liRequest* li_lua_get_request(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_request(lua_State *L, liRequest *req);
|
LI_API int li_lua_push_request(lua_State *L, liRequest *req);
|
||||||
|
|
||||||
LI_API liRequestUri* li_lua_get_requesturi(lua_State *L, int ndx);
|
LI_API liRequestUri* li_lua_get_requesturi(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_requesturi(lua_State *L, liRequestUri *uri);
|
LI_API int li_lua_push_requesturi(lua_State *L, liRequestUri *uri);
|
||||||
|
|
||||||
|
/* response_lua.c */
|
||||||
LI_API void li_lua_init_response_mt(lua_State *L);
|
LI_API void li_lua_init_response_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liResponse* li_lua_get_response(lua_State *L, int ndx);
|
LI_API liResponse* li_lua_get_response(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_response(lua_State *L, liResponse *resp);
|
LI_API int li_lua_push_response(lua_State *L, liResponse *resp);
|
||||||
|
|
||||||
|
/* stat_lua.c */
|
||||||
LI_API void li_lua_init_stat_mt(lua_State *L);
|
LI_API void li_lua_init_stat_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API struct stat* li_lua_get_stat(lua_State *L, int ndx);
|
LI_API struct stat* li_lua_get_stat(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_stat(lua_State *L, struct stat *st);
|
LI_API int li_lua_push_stat(lua_State *L, struct stat *st);
|
||||||
|
|
||||||
|
/* subrequest_lua.c */
|
||||||
LI_API void li_lua_init_subrequest_mt(lua_State *L);
|
LI_API void li_lua_init_subrequest_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API void li_lua_init_vrequest_mt(lua_State *L);
|
/* virtualrequest_lua.c */
|
||||||
|
LI_API void li_lua_init_virtualrequest_mt(lua_State *L);
|
||||||
|
|
||||||
LI_API liVRequest* li_lua_get_vrequest(lua_State *L, int ndx);
|
LI_API liVRequest* li_lua_get_vrequest(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_vrequest(lua_State *L, liVRequest *vr);
|
LI_API int li_lua_push_vrequest(lua_State *L, liVRequest *vr);
|
||||||
|
|
||||||
LI_API void li_lua_init_coninfo_mt(lua_State *L);
|
|
||||||
LI_API liConInfo* li_lua_get_coninfo(lua_State *L, int ndx);
|
LI_API liConInfo* li_lua_get_coninfo(lua_State *L, int ndx);
|
||||||
LI_API int li_lua_push_coninfo(lua_State *L, liConInfo *vr);
|
LI_API int li_lua_push_coninfo(lua_State *L, liConInfo *vr);
|
||||||
|
|
||||||
|
/* everything else: core_lua.c */
|
||||||
|
|
||||||
LI_API int li_lua_fixindex(lua_State *L, int ndx);
|
LI_API int li_lua_fixindex(lua_State *L, int ndx);
|
||||||
|
|
||||||
/* return 1 if value is found in mt (on top of the stack), 0 if it is not found (stack balance = 0)
|
/* return 1 if value is found in mt (on top of the stack), 0 if it is not found (stack balance = 0)
|
||||||
* table, key on stack at pos 0 and 1 (i.e. __index metho)
|
* table, key on stack at pos 0 and 1 (i.e. __index method)
|
||||||
*/
|
*/
|
||||||
LI_API int li_lua_metatable_index(lua_State *L);
|
LI_API int li_lua_metatable_index(lua_State *L);
|
||||||
|
|
||||||
@ -121,4 +142,18 @@ INLINE void li_lua_unlock(liLuaState *LL) {
|
|||||||
g_static_rec_mutex_unlock(&LL->lualock);
|
g_static_rec_mutex_unlock(&LL->lualock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INLINE void li_lua_protect_metatable(lua_State *L) {
|
||||||
|
/* __metatable key prevents accessing metatable of objects/tables in normal lua code */
|
||||||
|
lua_pushboolean(L, FALSE);
|
||||||
|
lua_setfield(L, -2, "__metatable");
|
||||||
|
}
|
||||||
|
|
||||||
|
INLINE int li_lua_new_protected_metatable(lua_State *L, const char *tname) {
|
||||||
|
int r = luaL_newmetatable(L, tname);
|
||||||
|
if (r) {
|
||||||
|
li_lua_protect_metatable(L);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,7 @@ enum {
|
|||||||
LI_EV_READ = 0x01,
|
LI_EV_READ = 0x01,
|
||||||
LI_EV_WRITE = 0x02,
|
LI_EV_WRITE = 0x02,
|
||||||
LI_EV_WAKEUP = 0x04
|
LI_EV_WAKEUP = 0x04
|
||||||
};
|
} HEDLEY_FLAGS;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LI_EVT_NONE = 0,
|
LI_EVT_NONE = 0,
|
||||||
|
2042
include/lighttpd/hedley.h
Normal file
2042
include/lighttpd/hedley.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -156,11 +156,11 @@ LI_API void li_log_context_set(liLogContext *context, liLogMap *log_map);
|
|||||||
|
|
||||||
LI_API gboolean li_log_write_direct(liServer *srv, liWorker *wrk, GString *path, GString *msg);
|
LI_API gboolean li_log_write_direct(liServer *srv, liWorker *wrk, GString *path, GString *msg);
|
||||||
/* li_log_write is used to write to the errorlog */
|
/* li_log_write is used to write to the errorlog */
|
||||||
LI_API gboolean li_log_write(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(6, 7);
|
LI_API gboolean li_log_write(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, const gchar *fmt, ...) HEDLEY_PRINTF_FORMAT(6, 7);
|
||||||
|
|
||||||
/* replaces '\r' and '\n' with '\0' */
|
/* replaces '\r' and '\n' with '\0' */
|
||||||
LI_API void li_log_split_lines(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
|
LI_API void li_log_split_lines(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
|
||||||
LI_API void li_log_split_lines_(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) G_GNUC_PRINTF(7, 8);
|
LI_API void li_log_split_lines_(liServer *srv, liWorker *wrk, liLogContext* context, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) HEDLEY_PRINTF_FORMAT(7, 8);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _LIGHTTPD_SETTINGS_H_
|
#ifndef _LIGHTTPD_SETTINGS_H_
|
||||||
#define _LIGHTTPD_SETTINGS_H_
|
#define _LIGHTTPD_SETTINGS_H_
|
||||||
|
|
||||||
|
#include <lighttpd/hedley.h>
|
||||||
|
|
||||||
/* check which OS we are compiling for */
|
/* check which OS we are compiling for */
|
||||||
#if defined(__BEOS__)
|
#if defined(__BEOS__)
|
||||||
# define LIGHTY_OS_BEOS
|
# define LIGHTY_OS_BEOS
|
||||||
@ -163,57 +165,15 @@
|
|||||||
# define USE_WRITE
|
# define USE_WRITE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Shared library support */
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define LI_IMPORT __declspec(dllimport)
|
|
||||||
#define LI_EXPORT __declspec(dllexport)
|
|
||||||
#define LI_DLLLOCAL
|
|
||||||
#define LI_DLLPUBLIC
|
|
||||||
#else
|
|
||||||
#define LI_IMPORT
|
|
||||||
#ifdef GCC_HASCLASSVISIBILITY
|
|
||||||
#define LI_EXPORT __attribute__ ((visibility("default")))
|
|
||||||
#define LI_DLLLOCAL __attribute__ ((visibility("hidden")))
|
|
||||||
#define LI_DLLPUBLIC __attribute__ ((visibility("default")))
|
|
||||||
#else
|
|
||||||
#define LI_EXPORT
|
|
||||||
#define LI_DLLLOCAL
|
|
||||||
#define LI_DLLPUBLIC
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LI_DECLARE_EXPORTS
|
#ifdef LI_DECLARE_EXPORTS
|
||||||
#define LI_API LI_EXPORT
|
# define LI_API HEDLEY_PUBLIC
|
||||||
#else
|
#else
|
||||||
#define LI_API LI_IMPORT
|
# define LI_API HEDLEY_IMPORT
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Throwable classes must always be visible on GCC in all binaries */
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define LI_EXCEPTIONAPI(api) api
|
|
||||||
#elif defined(GCC_HASCLASSVISIBILITY)
|
|
||||||
#define LI_EXCEPTIONAPI(api) LI_EXPORT
|
|
||||||
#else
|
|
||||||
#define LI_EXCEPTIONAPI(api)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef UNUSED_PARAM
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
# define UNUSED_PARAM(x) UNUSED_ ## x __attribute__((unused))
|
|
||||||
#elif defined(__LCLINT__)
|
|
||||||
# define UNUSED_PARAM(x) /*@unused@*/ x
|
|
||||||
#else
|
|
||||||
# define UNUSED_PARAM(x) x
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UNUSED(x) ( (void)(x) )
|
#define UNUSED(x) ( (void)(x) )
|
||||||
|
|
||||||
#if __GNUC__
|
#define INLINE static HEDLEY_INLINE
|
||||||
#define INLINE static inline
|
|
||||||
/* # define INLINE extern inline */
|
|
||||||
#else
|
|
||||||
# define INLINE static
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PACKAGE_NO_BUILD_DATE
|
#ifdef PACKAGE_NO_BUILD_DATE
|
||||||
# undef PACKAGE_BUILD_DATE
|
# undef PACKAGE_BUILD_DATE
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#define sockread( fd, buf, bytes ) recv( fd, buf, bytes, 0 )
|
#define sockread( fd, buf, bytes ) recv( fd, buf, bytes, 0 )
|
||||||
|
|
||||||
LI_EXPORT const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
LI_API const char * inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
|
||||||
int inet_aton(const char *cp, struct in_addr *inp);
|
int inet_aton(const char *cp, struct in_addr *inp);
|
||||||
#define HAVE_INET_ADDR
|
#define HAVE_INET_ADDR
|
||||||
#undef HAVE_INET_ATON
|
#undef HAVE_INET_ATON
|
||||||
|
@ -10,11 +10,11 @@ typedef enum {
|
|||||||
} liCounterType;
|
} liCounterType;
|
||||||
|
|
||||||
/* log message, print backtrace, and abort() (use LI_FATAL(msg) to call it) */
|
/* log message, print backtrace, and abort() (use LI_FATAL(msg) to call it) */
|
||||||
LI_API void li_fatal(const char *filename, unsigned int line, const char *function, const char *msg) G_GNUC_NORETURN;
|
LI_API void li_fatal(const char *filename, unsigned int line, const char *function, const char *msg) HEDLEY_NO_RETURN;
|
||||||
/* if libunwind is available this prints a backtrace to STDERR */
|
/* if libunwind is available this prints a backtrace to STDERR */
|
||||||
LI_API void li_print_backtrace_stderr(void);
|
LI_API void li_print_backtrace_stderr(void);
|
||||||
/* LI_FORCE_ASSERT is *always* active - in debug and release builds */
|
/* LI_FORCE_ASSERT is *always* active - in debug and release builds */
|
||||||
#define LI_FORCE_ASSERT(x) do { if (G_UNLIKELY(!(x))) li_fatal(__FILE__, __LINE__, G_STRFUNC, "Assertion `" #x "' failed."); } while(0)
|
#define LI_FORCE_ASSERT(x) do { if (HEDLEY_UNLIKELY(!(x))) li_fatal(__FILE__, __LINE__, G_STRFUNC, "Assertion `" #x "' failed."); } while(0)
|
||||||
#define LI_FATAL(msg) li_fatal(__FILE__, __LINE__, G_STRFUNC, msg)
|
#define LI_FATAL(msg) li_fatal(__FILE__, __LINE__, G_STRFUNC, msg)
|
||||||
|
|
||||||
/* set O_NONBLOCK and FD_CLOEXEC */
|
/* set O_NONBLOCK and FD_CLOEXEC */
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <lighttpd/base.h>
|
#include <lighttpd/base.h>
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
|
|
||||||
|
LI_API void li_lua_init_value_mt(lua_State *L);
|
||||||
|
|
||||||
/* converts the top of the stack into an value
|
/* converts the top of the stack into an value
|
||||||
* and pops the value
|
* and pops the value
|
||||||
* returns NULL if it couldn't convert the value (still pops it)
|
* returns NULL if it couldn't convert the value (still pops it)
|
||||||
|
@ -72,7 +72,7 @@ struct liConfigTokenizerContext {
|
|||||||
GHashTable *variables;
|
GHashTable *variables;
|
||||||
};
|
};
|
||||||
|
|
||||||
static liConfigToken tokenizer_error(liConfigTokenizerContext *ctx, GError **error, const char *fmt, ...) G_GNUC_PRINTF(3, 4);
|
static liConfigToken tokenizer_error(liConfigTokenizerContext *ctx, GError **error, const char *fmt, ...) HEDLEY_PRINTF_FORMAT(3, 4);
|
||||||
|
|
||||||
GQuark li_angel_config_parser_error_quark(void) {
|
GQuark li_angel_config_parser_error_quark(void) {
|
||||||
return g_quark_from_string("li-angel-config-parser-error-quark");
|
return g_quark_from_string("li-angel-config-parser-error-quark");
|
||||||
|
@ -158,7 +158,7 @@ static inline gsize mp_align_size(gsize size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gsize li_mempool_align_page_size(gsize size) {
|
gsize li_mempool_align_page_size(gsize size) {
|
||||||
if (G_UNLIKELY(!mp_initialized)) {
|
if (HEDLEY_UNLIKELY(!mp_initialized)) {
|
||||||
mempool_init();
|
mempool_init();
|
||||||
}
|
}
|
||||||
return mp_align_size(size);
|
return mp_align_size(size);
|
||||||
@ -167,17 +167,17 @@ gsize li_mempool_align_page_size(gsize size) {
|
|||||||
static inline void* mp_alloc_page(gsize size) {
|
static inline void* mp_alloc_page(gsize size) {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
# ifdef MAP_ANON
|
# ifdef MAP_ANON
|
||||||
if (G_UNLIKELY(MAP_FAILED == (ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0)))) {
|
if (HEDLEY_UNLIKELY(MAP_FAILED == (ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0)))) {
|
||||||
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes with mmap", G_STRLOC, size);
|
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes with mmap", G_STRLOC, size);
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
if (G_UNLIKELY(NULL == (ptr = g_malloc(size)))) {
|
if (HEDLEY_UNLIKELY(NULL == (ptr = g_malloc(size)))) {
|
||||||
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes", G_STRLOC, size);
|
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes", G_STRLOC, size);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef WITH_PROFILER
|
#ifdef WITH_PROFILER
|
||||||
if (G_UNLIKELY(li_profiler_enabled)) {
|
if (HEDLEY_UNLIKELY(li_profiler_enabled)) {
|
||||||
li_profiler_hashtable_insert((gpointer)ptr, size);
|
li_profiler_hashtable_insert((gpointer)ptr, size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -195,7 +195,7 @@ static inline void mp_free_page(const void *ptr, gsize size) {
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#ifdef WITH_PROFILER
|
#ifdef WITH_PROFILER
|
||||||
if (G_UNLIKELY(li_profiler_enabled)) {
|
if (HEDLEY_UNLIKELY(li_profiler_enabled)) {
|
||||||
li_profiler_hashtable_remove((gpointer)ptr);
|
li_profiler_hashtable_remove((gpointer)ptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -299,7 +299,7 @@ static inline void mp_mag_free(mp_magazine *mag, void *ptr) {
|
|||||||
if (id == mag->next - 1) mag->next--; /* if chunk was just allocated, "undo" it */
|
if (id == mag->next - 1) mag->next--; /* if chunk was just allocated, "undo" it */
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (G_UNLIKELY(0 == mag->used)) {
|
if (HEDLEY_UNLIKELY(0 == mag->used)) {
|
||||||
mp_free_page(mag->data, mag->count * mag->chunksize);
|
mp_free_page(mag->data, mag->count * mag->chunksize);
|
||||||
mag->data = NULL;
|
mag->data = NULL;
|
||||||
# ifndef MP_SEARCH_BITVECTOR
|
# ifndef MP_SEARCH_BITVECTOR
|
||||||
@ -363,16 +363,16 @@ static inline mp_pool* mp_pools_get(gsize size) {
|
|||||||
mp_pool *pool;
|
mp_pool *pool;
|
||||||
|
|
||||||
pools = g_private_get(thread_pools);
|
pools = g_private_get(thread_pools);
|
||||||
if (G_UNLIKELY(!pools)) {
|
if (HEDLEY_UNLIKELY(!pools)) {
|
||||||
pools = g_slice_new0(mp_pools);
|
pools = g_slice_new0(mp_pools);
|
||||||
g_private_set(thread_pools, pools);
|
g_private_set(thread_pools, pools);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iter = pools->queue.head; iter; iter = iter->next) {
|
for (iter = pools->queue.head; iter; iter = iter->next) {
|
||||||
pool = iter->data;
|
pool = iter->data;
|
||||||
if (G_LIKELY(pool->chunksize == size)) {
|
if (HEDLEY_LIKELY(pool->chunksize == size)) {
|
||||||
goto done;
|
goto done;
|
||||||
} else if (G_UNLIKELY(pool->chunksize > size)) {
|
} else if (HEDLEY_UNLIKELY(pool->chunksize > size)) {
|
||||||
pool = mp_pool_new(size);
|
pool = mp_pool_new(size);
|
||||||
_queue_insert_before(&pools->queue, iter, &pool->pools_list);
|
_queue_insert_before(&pools->queue, iter, &pool->pools_list);
|
||||||
goto done;
|
goto done;
|
||||||
@ -392,15 +392,15 @@ liMempoolPtr li_mempool_alloc(gsize size) {
|
|||||||
mp_magazine *mag;
|
mp_magazine *mag;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
if (G_UNLIKELY(!mp_initialized)) {
|
if (HEDLEY_UNLIKELY(!mp_initialized)) {
|
||||||
mempool_init();
|
mempool_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
size = mp_align_size(size);
|
size = mp_align_size(size);
|
||||||
|
|
||||||
/* mp_alloc_page fallback */
|
/* mp_alloc_page fallback */
|
||||||
if (G_UNLIKELY(size > MP_MAX_ALLOC_SIZE/MP_MIN_ALLOC_COUNT)) {
|
if (HEDLEY_UNLIKELY(size > MP_MAX_ALLOC_SIZE/MP_MIN_ALLOC_COUNT)) {
|
||||||
if (G_UNLIKELY(NULL == (ptr.data = mp_alloc_page(size)))) {
|
if (HEDLEY_UNLIKELY(NULL == (ptr.data = mp_alloc_page(size)))) {
|
||||||
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes", G_STRLOC, size);
|
g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes", G_STRLOC, size);
|
||||||
}
|
}
|
||||||
return ptr;
|
return ptr;
|
||||||
@ -411,12 +411,12 @@ liMempoolPtr li_mempool_alloc(gsize size) {
|
|||||||
/* Try to lock a unlocked magazine if possible; creating new magazines is allowed
|
/* Try to lock a unlocked magazine if possible; creating new magazines is allowed
|
||||||
* (new ones can't be locked as only the current thread knows this magazine)
|
* (new ones can't be locked as only the current thread knows this magazine)
|
||||||
* Spinlock the first magazine if first strategy failed */
|
* Spinlock the first magazine if first strategy failed */
|
||||||
if (G_LIKELY(pool->magazines[0])) {
|
if (HEDLEY_LIKELY(pool->magazines[0])) {
|
||||||
/* at least one magazine available */
|
/* at least one magazine available */
|
||||||
for (i = 0; i < MP_MAX_MAGAZINES; i++) {
|
for (i = 0; i < MP_MAX_MAGAZINES; i++) {
|
||||||
mag = pool->magazines[i];
|
mag = pool->magazines[i];
|
||||||
if (!mag) break;
|
if (!mag) break;
|
||||||
if (G_LIKELY(MP_TRYLOCK(mag->mutex))) {
|
if (HEDLEY_LIKELY(MP_TRYLOCK(mag->mutex))) {
|
||||||
goto found_mag;
|
goto found_mag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -436,9 +436,9 @@ found_mag:
|
|||||||
mp_mag_acquire(mag); /* keep track of chunk count */
|
mp_mag_acquire(mag); /* keep track of chunk count */
|
||||||
|
|
||||||
# ifndef MP_SEARCH_BITVECTOR
|
# ifndef MP_SEARCH_BITVECTOR
|
||||||
if (G_UNLIKELY(mag->next == mag->count)) {
|
if (HEDLEY_UNLIKELY(mag->next == mag->count)) {
|
||||||
# else
|
# else
|
||||||
if (G_UNLIKELY(mag->used == mag->count)) {
|
if (HEDLEY_UNLIKELY(mag->used == mag->count)) {
|
||||||
# endif
|
# endif
|
||||||
/* full magazine; remove from pool */
|
/* full magazine; remove from pool */
|
||||||
guint j;
|
guint j;
|
||||||
@ -468,7 +468,7 @@ void li_mempool_free(liMempoolPtr ptr, gsize size) {
|
|||||||
size = mp_align_size(size);
|
size = mp_align_size(size);
|
||||||
|
|
||||||
/* mp_alloc_page fallback */
|
/* mp_alloc_page fallback */
|
||||||
if (G_UNLIKELY(size > MP_MAX_ALLOC_SIZE/MP_MIN_ALLOC_COUNT)) {
|
if (HEDLEY_UNLIKELY(size > MP_MAX_ALLOC_SIZE/MP_MIN_ALLOC_COUNT)) {
|
||||||
mp_free_page(ptr.data, size);
|
mp_free_page(ptr.data, size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ void li_mempool_cleanup(void) {
|
|||||||
/* "Force" thread-private cleanup */
|
/* "Force" thread-private cleanup */
|
||||||
mp_pools *pools;
|
mp_pools *pools;
|
||||||
|
|
||||||
if (G_UNLIKELY(!mp_initialized)) {
|
if (HEDLEY_UNLIKELY(!mp_initialized)) {
|
||||||
mempool_init();
|
mempool_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void li_waitqueue_update(liWaitQueue *queue) {
|
|||||||
li_tstamp repeat;
|
li_tstamp repeat;
|
||||||
li_tstamp now = li_event_now(li_event_get_loop(&queue->timer));
|
li_tstamp now = li_event_now(li_event_get_loop(&queue->timer));
|
||||||
|
|
||||||
if (G_LIKELY(queue->head)) {
|
if (HEDLEY_LIKELY(queue->head)) {
|
||||||
repeat = queue->head->ts + queue->delay - now;
|
repeat = queue->head->ts + queue->delay - now;
|
||||||
|
|
||||||
if (repeat < 0.05) repeat = 0.05;
|
if (repeat < 0.05) repeat = 0.05;
|
||||||
@ -85,7 +85,7 @@ void li_waitqueue_push(liWaitQueue *queue, liWaitQueueElem *elem) {
|
|||||||
queue->tail = elem;
|
queue->tail = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY(!li_event_active(&queue->timer)))
|
if (HEDLEY_UNLIKELY(!li_event_active(&queue->timer)))
|
||||||
li_event_timer_once(&queue->timer, queue->delay);
|
li_event_timer_once(&queue->timer, queue->delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ void li_waitqueue_remove(liWaitQueue *queue, liWaitQueueElem *elem) {
|
|||||||
elem->queued = FALSE;
|
elem->queued = FALSE;
|
||||||
queue->length--;
|
queue->length--;
|
||||||
|
|
||||||
if (G_UNLIKELY(!queue->head))
|
if (HEDLEY_UNLIKELY(!queue->head))
|
||||||
li_event_stop(&queue->timer);
|
li_event_stop(&queue->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,23 +3,8 @@
|
|||||||
#include <lighttpd/config_lua.h>
|
#include <lighttpd/config_lua.h>
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_ACTION "liAction*"
|
#define LUA_ACTION "liAction*"
|
||||||
|
|
||||||
liAction* li_lua_get_action(lua_State *L, int ndx) {
|
|
||||||
if (!lua_isuserdata(L, ndx)) return NULL;
|
|
||||||
if (!lua_getmetatable(L, ndx)) return NULL;
|
|
||||||
luaL_getmetatable(L, LUA_ACTION);
|
|
||||||
if (lua_isnil(L, -1) || lua_isnil(L, -2) || !lua_equal(L, -1, -2)) {
|
|
||||||
lua_pop(L, 2);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
lua_pop(L, 2);
|
|
||||||
return *(liAction**) lua_touserdata(L, ndx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lua_action_gc(lua_State *L) {
|
static int lua_action_gc(lua_State *L) {
|
||||||
liServer *srv;
|
liServer *srv;
|
||||||
liLuaState *LL = li_lua_state_get(L);
|
liLuaState *LL = li_lua_state_get(L);
|
||||||
@ -35,6 +20,35 @@ static int lua_action_gc(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HEDLEY_NEVER_INLINE void init_action_mt(liServer *srv, lua_State *L) {
|
||||||
|
lua_pushlightuserdata(L, srv);
|
||||||
|
lua_pushcclosure(L, lua_action_gc, 1);
|
||||||
|
lua_setfield(L, -2, "__gc");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_action_metatable(liServer *srv, lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_ACTION)) {
|
||||||
|
init_action_mt(srv, L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_action_mt(liServer *srv, lua_State *L) {
|
||||||
|
lua_push_action_metatable(srv, L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
liAction* li_lua_get_action(lua_State *L, int ndx) {
|
||||||
|
if (!lua_isuserdata(L, ndx)) return NULL;
|
||||||
|
if (!lua_getmetatable(L, ndx)) return NULL;
|
||||||
|
luaL_getmetatable(L, LUA_ACTION);
|
||||||
|
if (lua_isnil(L, -1) || lua_isnil(L, -2) || !lua_equal(L, -1, -2)) {
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return *(liAction**) lua_touserdata(L, ndx);
|
||||||
|
}
|
||||||
|
|
||||||
int li_lua_push_action(liServer *srv, lua_State *L, liAction *a) {
|
int li_lua_push_action(liServer *srv, lua_State *L, liAction *a) {
|
||||||
liAction **pa;
|
liAction **pa;
|
||||||
|
|
||||||
@ -46,12 +60,7 @@ int li_lua_push_action(liServer *srv, lua_State *L, liAction *a) {
|
|||||||
pa = (liAction**) lua_newuserdata(L, sizeof(liAction*));
|
pa = (liAction**) lua_newuserdata(L, sizeof(liAction*));
|
||||||
*pa = a;
|
*pa = a;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_ACTION)) {
|
lua_push_action_metatable(srv, L);
|
||||||
lua_pushlightuserdata(L, srv);
|
|
||||||
lua_pushcclosure(L, lua_action_gc, 1);
|
|
||||||
lua_setfield(L, -2, "__gc");
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -176,6 +185,7 @@ liAction* li_lua_make_action(lua_State *L, int ndx) {
|
|||||||
lua_newtable(L); /* +1 */
|
lua_newtable(L); /* +1 */
|
||||||
/* new mt */
|
/* new mt */
|
||||||
lua_newtable(L); /* +1 */
|
lua_newtable(L); /* +1 */
|
||||||
|
/* TODO: protect metatable? */
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, LI_LUA_REGISTRY_GLOBALS); /* +1 */
|
lua_getfield(L, LUA_REGISTRYINDEX, LI_LUA_REGISTRY_GLOBALS); /* +1 */
|
||||||
lua_setfield(L, -2, "__index"); /* -1 */
|
lua_setfield(L, -2, "__index"); /* -1 */
|
||||||
lua_setmetatable(L, -2); /* -1 */
|
lua_setmetatable(L, -2); /* -1 */
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#ifdef HAVE_LUA_H
|
#ifdef HAVE_LUA_H
|
||||||
# include <lighttpd/core_lua.h>
|
# include <lighttpd/core_lua.h>
|
||||||
# include <lualib.h>
|
# include <lualib.h>
|
||||||
# include <lauxlib.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LUA_H
|
#ifdef HAVE_LUA_H
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define LUA_CHUNK "liChunk*"
|
#define LUA_CHUNK "liChunk*"
|
||||||
#define LUA_CHUNKQUEUE "liChunkQueue*"
|
#define LUA_CHUNKQUEUE "liChunkQueue*"
|
||||||
|
|
||||||
static void init_chunk_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_chunk_mt(lua_State *L) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
UNUSED(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_chunk_metatable(lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_CHUNK)) {
|
||||||
|
init_chunk_mt(L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*lua_ChunkQueue_Attrib)(liChunkQueue *cq, lua_State *L);
|
typedef int (*lua_ChunkQueue_Attrib)(liChunkQueue *cq, lua_State *L);
|
||||||
@ -259,19 +263,21 @@ static const luaL_Reg chunkqueue_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_chunkqueue_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_chunkqueue_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, chunkqueue_mt);
|
luaL_register(L, NULL, chunkqueue_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_chunk_mt(lua_State *L) {
|
static void lua_push_chunkqueue_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_CHUNK)) {
|
if (li_lua_new_protected_metatable(L, LUA_CHUNKQUEUE)) {
|
||||||
init_chunk_mt(L);
|
|
||||||
}
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_CHUNKQUEUE)) {
|
|
||||||
init_chunkqueue_mt(L);
|
init_chunkqueue_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_chunk_mt(lua_State *L) {
|
||||||
|
lua_push_chunk_metatable(L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_push_chunkqueue_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,10 +304,7 @@ int li_lua_push_chunk(lua_State *L, liChunk *c) {
|
|||||||
pc = (liChunk**) lua_newuserdata(L, sizeof(liChunk*));
|
pc = (liChunk**) lua_newuserdata(L, sizeof(liChunk*));
|
||||||
*pc = c;
|
*pc = c;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_CHUNK)) {
|
lua_push_chunk_metatable(L);
|
||||||
init_chunk_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -329,10 +332,7 @@ int li_lua_push_chunkqueue(lua_State *L, liChunkQueue *cq) {
|
|||||||
pcq = (liChunkQueue**) lua_newuserdata(L, sizeof(liChunkQueue*));
|
pcq = (liChunkQueue**) lua_newuserdata(L, sizeof(liChunkQueue*));
|
||||||
*pcq = cq;
|
*pcq = cq;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_CHUNKQUEUE)) {
|
lua_push_chunkqueue_metatable(L);
|
||||||
init_chunkqueue_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
|
|
||||||
|
#include <lighttpd/core_lua.h>
|
||||||
#include <lighttpd/condition_lua.h>
|
#include <lighttpd/condition_lua.h>
|
||||||
#include <lighttpd/value_lua.h>
|
#include <lighttpd/value_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_CONDITION "liCondition*"
|
#define LUA_CONDITION "liCondition*"
|
||||||
#define LUA_COND_LVALUE "liConditionLValue*"
|
#define LUA_COND_LVALUE "liConditionLValue*"
|
||||||
#define LUA_COND_LVALUE_T "liCondLValue"
|
#define LUA_COND_LVALUE_T "liCondLValue"
|
||||||
@ -113,9 +111,13 @@ static int lua_cond_lvalue_gc(lua_State *L) {
|
|||||||
|
|
||||||
/* new metatables and push */
|
/* new metatables and push */
|
||||||
|
|
||||||
static void lua_push_condition_metatable(liServer *srv, lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_condition_mt(liServer *srv, lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_CONDITION)) {
|
|
||||||
lua_mt_register_srv(srv, L, "__gc", lua_condition_gc);
|
lua_mt_register_srv(srv, L, "__gc", lua_condition_gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_condition_metatable(liServer *srv, lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_CONDITION)) {
|
||||||
|
init_condition_mt(srv, L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +133,6 @@ int li_lua_push_condition(liServer *srv, lua_State *L, liCondition *c) {
|
|||||||
*pc = c;
|
*pc = c;
|
||||||
|
|
||||||
lua_push_condition_metatable(srv, L);
|
lua_push_condition_metatable(srv, L);
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -193,8 +194,7 @@ static int lua_cond_lvalue_cmp(lua_State *L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lua_push_cond_lvalue_metatable(liServer *srv, lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_cond_lvalue_mt(liServer *srv, lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_COND_LVALUE)) {
|
|
||||||
lua_mt_register(L, "__gc", lua_cond_lvalue_gc);
|
lua_mt_register(L, "__gc", lua_cond_lvalue_gc);
|
||||||
lua_mt_register(L, "__tostring", lua_cond_lvalue_tostring);
|
lua_mt_register(L, "__tostring", lua_cond_lvalue_tostring);
|
||||||
|
|
||||||
@ -218,6 +218,11 @@ static void lua_push_cond_lvalue_metatable(liServer *srv, lua_State *L) {
|
|||||||
|
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_cond_lvalue_metatable(liServer *srv, lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_COND_LVALUE)) {
|
||||||
|
init_cond_lvalue_mt(srv, L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +233,6 @@ static int lua_push_cond_lvalue(liServer *srv, lua_State *L, liConditionLValue *
|
|||||||
*pv = lvalue;
|
*pv = lvalue;
|
||||||
|
|
||||||
lua_push_cond_lvalue_metatable(srv, L);
|
lua_push_cond_lvalue_metatable(srv, L);
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -252,13 +256,28 @@ static int lua_cond_lvalue_t_index(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lua_push_cond_lvalue_t_metatable(liServer *srv, lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_cond_lvalue_t_mt(liServer *srv, lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_COND_LVALUE_T)) {
|
|
||||||
lua_mt_register(L, "__tostring", lua_cond_lvalue_t_tostring);
|
lua_mt_register(L, "__tostring", lua_cond_lvalue_t_tostring);
|
||||||
lua_mt_register_srv(srv, L, "__index", lua_cond_lvalue_t_index);
|
lua_mt_register_srv(srv, L, "__index", lua_cond_lvalue_t_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_cond_lvalue_t_metatable(liServer *srv, lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_COND_LVALUE_T)) {
|
||||||
|
init_cond_lvalue_t_mt(srv, L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void li_lua_init_condition_mt(liServer *srv, lua_State *L) {
|
||||||
|
lua_push_condition_metatable(srv, L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_push_cond_lvalue_metatable(srv, L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_push_cond_lvalue_t_metatable(srv, L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* cond_lvalue_t */
|
/* cond_lvalue_t */
|
||||||
|
|
||||||
static int lua_push_cond_lvalue_t(liServer *srv, lua_State *L, liCondLValue t) {
|
static int lua_push_cond_lvalue_t(liServer *srv, lua_State *L, liCondLValue t) {
|
||||||
@ -268,7 +287,6 @@ static int lua_push_cond_lvalue_t(liServer *srv, lua_State *L, liCondLValue t) {
|
|||||||
*pt = t;
|
*pt = t;
|
||||||
|
|
||||||
lua_push_cond_lvalue_t_metatable(srv, L);
|
lua_push_cond_lvalue_t_metatable(srv, L);
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
typedef int (*LuaWrapper)(liServer *srv, liWorker *wrk, lua_State *L, const char *key);
|
typedef int (*LuaWrapper)(liServer *srv, liWorker *wrk, lua_State *L, const char *key);
|
||||||
|
|
||||||
static liValue* lua_params_to_value(liServer *srv, lua_State *L) {
|
static liValue* lua_params_to_value(liServer *srv, lua_State *L) {
|
||||||
@ -49,26 +46,30 @@ static int _lua_dynamic_hash_index_call(lua_State *L) {
|
|||||||
static int _lua_dynamic_hash_index(lua_State *L) {
|
static int _lua_dynamic_hash_index(lua_State *L) {
|
||||||
int key_ndx;
|
int key_ndx;
|
||||||
|
|
||||||
lua_pushvalue(L, lua_upvalueindex(4));
|
/* upvalues: 1: srv, 2: wrk, 3: "wrapper", 4: key prefix */
|
||||||
|
|
||||||
|
/* concat key prefix and new sub key */
|
||||||
|
lua_pushvalue(L, lua_upvalueindex(4)); /* key prefix */
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
lua_concat(L, 2);
|
lua_concat(L, 2);
|
||||||
key_ndx = lua_gettop(L);
|
key_ndx = lua_gettop(L);
|
||||||
|
|
||||||
lua_newtable(L); /* result */
|
lua_newuserdata(L, 0); /* result: zero-sized userdata object */
|
||||||
lua_newtable(L); /* meta table */
|
lua_newtable(L); /* meta table */
|
||||||
|
li_lua_protect_metatable(L);
|
||||||
|
|
||||||
/* call method */
|
/* call method */
|
||||||
lua_pushvalue(L, lua_upvalueindex(1));
|
lua_pushvalue(L, lua_upvalueindex(1)); /* srv */
|
||||||
lua_pushvalue(L, lua_upvalueindex(2));
|
lua_pushvalue(L, lua_upvalueindex(2)); /* wrk */
|
||||||
lua_pushvalue(L, lua_upvalueindex(3));
|
lua_pushvalue(L, lua_upvalueindex(3)); /* wrapper */
|
||||||
lua_pushvalue(L, key_ndx);
|
lua_pushvalue(L, key_ndx);
|
||||||
lua_pushcclosure(L, _lua_dynamic_hash_index_call, 4);
|
lua_pushcclosure(L, _lua_dynamic_hash_index_call, 4);
|
||||||
lua_setfield(L, -2, "__call");
|
lua_setfield(L, -2, "__call");
|
||||||
|
|
||||||
/* index for "nested" keys */
|
/* index for "nested" keys */
|
||||||
lua_pushvalue(L, lua_upvalueindex(1));
|
lua_pushvalue(L, lua_upvalueindex(1)); /* srv */
|
||||||
lua_pushvalue(L, lua_upvalueindex(2));
|
lua_pushvalue(L, lua_upvalueindex(2)); /* wrk */
|
||||||
lua_pushvalue(L, lua_upvalueindex(3));
|
lua_pushvalue(L, lua_upvalueindex(3)); /* wrapper */
|
||||||
lua_pushvalue(L, key_ndx); /* append a "." to the current key for nesting */
|
lua_pushvalue(L, key_ndx); /* append a "." to the current key for nesting */
|
||||||
lua_pushstring(L, ".");
|
lua_pushstring(L, ".");
|
||||||
lua_concat(L, 2);
|
lua_concat(L, 2);
|
||||||
@ -81,14 +82,17 @@ static int _lua_dynamic_hash_index(lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void lua_push_dynamic_hash(liServer *srv, liWorker *wrk, lua_State *L, LuaWrapper wrapper) {
|
static void lua_push_dynamic_hash(liServer *srv, liWorker *wrk, lua_State *L, LuaWrapper wrapper) {
|
||||||
lua_newtable(L);
|
lua_newuserdata(L, 0); /* result: zero-sized userdata object */
|
||||||
lua_newtable(L); /* meta table */
|
lua_newtable(L); /* meta table */
|
||||||
|
li_lua_protect_metatable(L);
|
||||||
|
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushlightuserdata(L, (void*)(intptr_t) wrapper);
|
lua_pushlightuserdata(L, (void*)(intptr_t) wrapper);
|
||||||
lua_pushstring(L, ""); /* nesting starts at "root" with empty string */
|
lua_pushstring(L, ""); /* nesting starts at "root" with empty string */
|
||||||
lua_pushcclosure(L, _lua_dynamic_hash_index, 4);
|
lua_pushcclosure(L, _lua_dynamic_hash_index, 4);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ struct liConditionTree {
|
|||||||
liConditionTree *left, *right;
|
liConditionTree *left, *right;
|
||||||
};
|
};
|
||||||
|
|
||||||
static liConfigToken tokenizer_error(liConfigTokenizerContext *ctx, GError **error, const char *fmt, ...) G_GNUC_PRINTF(3, 4);
|
static liConfigToken tokenizer_error(liConfigTokenizerContext *ctx, GError **error, const char *fmt, ...) HEDLEY_PRINTF_FORMAT(3, 4);
|
||||||
|
|
||||||
GQuark li_config_error_quark(void) {
|
GQuark li_config_error_quark(void) {
|
||||||
return g_quark_from_string("li-config-error-quark");
|
return g_quark_from_string("li-config-error-quark");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
#include <lighttpd/actions_lua.h>
|
||||||
#include <lualib.h>
|
#include <lighttpd/condition_lua.h>
|
||||||
#include <lauxlib.h>
|
#include <lighttpd/value_lua.h>
|
||||||
|
|
||||||
liLuaState *li_lua_state_get(lua_State *L) {
|
liLuaState *li_lua_state_get(lua_State *L) {
|
||||||
liLuaState *LL;
|
liLuaState *LL;
|
||||||
@ -315,7 +315,7 @@ static int li_lua_kvl_to_table(lua_State *L) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void lua_push_constants(lua_State *L, int ndx) {
|
static void li_lua_push_lighty_constants(lua_State *L, int ndx) {
|
||||||
lua_pushinteger(L, LI_HANDLER_GO_ON);
|
lua_pushinteger(L, LI_HANDLER_GO_ON);
|
||||||
lua_setfield(L, ndx, "HANDLER_GO_ON");
|
lua_setfield(L, ndx, "HANDLER_GO_ON");
|
||||||
lua_pushinteger(L, LI_HANDLER_COMEBACK);
|
lua_pushinteger(L, LI_HANDLER_COMEBACK);
|
||||||
@ -330,15 +330,22 @@ void li_lua_init2(liLuaState *LL, liServer *srv, liWorker *wrk) {
|
|||||||
lua_State *L = LL->L;
|
lua_State *L = LL->L;
|
||||||
|
|
||||||
li_lua_init_chunk_mt(L);
|
li_lua_init_chunk_mt(L);
|
||||||
li_lua_init_coninfo_mt(L);
|
|
||||||
li_lua_init_environment_mt(L);
|
li_lua_init_environment_mt(L);
|
||||||
li_lua_init_filter_mt(L);
|
li_lua_init_filter_mt(L);
|
||||||
|
li_lua_init_http_headers_mt(L);
|
||||||
li_lua_init_physical_mt(L);
|
li_lua_init_physical_mt(L);
|
||||||
li_lua_init_request_mt(L);
|
li_lua_init_request_mt(L);
|
||||||
li_lua_init_response_mt(L);
|
li_lua_init_response_mt(L);
|
||||||
li_lua_init_vrequest_mt(L);
|
|
||||||
|
|
||||||
li_lua_init_stat_mt(L);
|
li_lua_init_stat_mt(L);
|
||||||
|
li_lua_init_subrequest_mt(L);
|
||||||
|
li_lua_init_virtualrequest_mt(L);
|
||||||
|
|
||||||
|
if (NULL == wrk) {
|
||||||
|
/* these should only be used in the "main" lua context */
|
||||||
|
li_lua_init_action_mt(srv, L);
|
||||||
|
li_lua_init_condition_mt(srv, L);
|
||||||
|
li_lua_init_value_mt(L);
|
||||||
|
}
|
||||||
|
|
||||||
/* prefer closure, but just in case */
|
/* prefer closure, but just in case */
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
@ -348,9 +355,16 @@ void li_lua_init2(liLuaState *LL, liServer *srv, liWorker *wrk) {
|
|||||||
lua_setfield(L, LUA_REGISTRYINDEX, LI_LUA_REGISTRY_WORKER);
|
lua_setfield(L, LUA_REGISTRYINDEX, LI_LUA_REGISTRY_WORKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_newtable(L); /* lighty. */
|
/* create read-only lighty "table" (zero-sized userdata object) */
|
||||||
|
lua_newuserdata(L, 0); /* lighty. */
|
||||||
|
lua_newtable(L); /* metatable(lighty) */
|
||||||
|
/* prevent tampering with the metatable */
|
||||||
|
li_lua_protect_metatable(L);
|
||||||
|
lua_newtable(L); /* metatable(lighty).__index */
|
||||||
|
/* create lighty.filter_in and lighty.filter_out: */
|
||||||
li_lua_init_filters(L, srv);
|
li_lua_init_filters(L, srv);
|
||||||
|
|
||||||
|
/* lighty.print (and lighty.error and global print) */
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushcclosure(L, li_lua_error, 2);
|
lua_pushcclosure(L, li_lua_error, 2);
|
||||||
@ -360,21 +374,25 @@ void li_lua_init2(liLuaState *LL, liServer *srv, liWorker *wrk) {
|
|||||||
lua_setfield(L, -3, "error");
|
lua_setfield(L, -3, "error");
|
||||||
lua_setfield(L, -2, "print");
|
lua_setfield(L, -2, "print");
|
||||||
|
|
||||||
|
/* lighty.warning */
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushcclosure(L, li_lua_warning, 2);
|
lua_pushcclosure(L, li_lua_warning, 2);
|
||||||
lua_setfield(L, -2, "warning");
|
lua_setfield(L, -2, "warning");
|
||||||
|
|
||||||
|
/* lighty.info */
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushcclosure(L, li_lua_info, 2);
|
lua_pushcclosure(L, li_lua_info, 2);
|
||||||
lua_setfield(L, -2, "info");
|
lua_setfield(L, -2, "info");
|
||||||
|
|
||||||
|
/* lighty.debug */
|
||||||
lua_pushlightuserdata(L, srv);
|
lua_pushlightuserdata(L, srv);
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushcclosure(L, li_lua_debug, 2);
|
lua_pushcclosure(L, li_lua_debug, 2);
|
||||||
lua_setfield(L, -2, "debug");
|
lua_setfield(L, -2, "debug");
|
||||||
|
|
||||||
|
/* lighty.{md5,sha1,sha256} */
|
||||||
lua_pushcclosure(L, li_lua_md5, 0);
|
lua_pushcclosure(L, li_lua_md5, 0);
|
||||||
lua_setfield(L, -2, "md5");
|
lua_setfield(L, -2, "md5");
|
||||||
lua_pushcclosure(L, li_lua_sha1, 0);
|
lua_pushcclosure(L, li_lua_sha1, 0);
|
||||||
@ -382,11 +400,17 @@ void li_lua_init2(liLuaState *LL, liServer *srv, liWorker *wrk) {
|
|||||||
lua_pushcclosure(L, li_lua_sha256, 0);
|
lua_pushcclosure(L, li_lua_sha256, 0);
|
||||||
lua_setfield(L, -2, "sha256");
|
lua_setfield(L, -2, "sha256");
|
||||||
|
|
||||||
|
/* lighty.path_simplify */
|
||||||
lua_pushcclosure(L, li_lua_path_simplify, 0);
|
lua_pushcclosure(L, li_lua_path_simplify, 0);
|
||||||
lua_setfield(L, -2, "path_simplify");
|
lua_setfield(L, -2, "path_simplify");
|
||||||
|
|
||||||
lua_push_constants(L, -2);
|
li_lua_push_lighty_constants(L, -2);
|
||||||
|
|
||||||
|
/* set __index for metatable(lighty) */
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
/* associate metatable(lighty) */
|
||||||
|
lua_setmetatable(L, -2);
|
||||||
|
/* store "lighty" object in globals */
|
||||||
lua_setfield(L, LUA_GLOBALSINDEX, "lighty");
|
lua_setfield(L, LUA_GLOBALSINDEX, "lighty");
|
||||||
|
|
||||||
li_lua_store_globals(L);
|
li_lua_store_globals(L);
|
||||||
@ -404,6 +428,7 @@ void li_lua_new_globals(lua_State *L) {
|
|||||||
|
|
||||||
/* metatable for new global env, link old globals as readonly */
|
/* metatable for new global env, link old globals as readonly */
|
||||||
lua_newtable(L); /* +1 */
|
lua_newtable(L); /* +1 */
|
||||||
|
/* TODO: protect metatable? */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX); /* +1 */
|
lua_pushvalue(L, LUA_GLOBALSINDEX); /* +1 */
|
||||||
lua_setfield(L, -2, "__index"); /* -1 */
|
lua_setfield(L, -2, "__index"); /* -1 */
|
||||||
lua_setmetatable(L, -2); /* -1 */
|
lua_setmetatable(L, -2); /* -1 */
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_ENVIRONMENT "liEnvironment*"
|
#define LUA_ENVIRONMENT "liEnvironment*"
|
||||||
|
|
||||||
static int lua_environment_get(lua_State *L) {
|
static int lua_environment_get(lua_State *L) {
|
||||||
@ -113,14 +110,18 @@ static const luaL_Reg environment_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_env_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_env_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, environment_mt);
|
luaL_register(L, NULL, environment_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_environment_mt(lua_State *L) {
|
static void lua_push_environment_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_ENVIRONMENT)) {
|
if (li_lua_new_protected_metatable(L, LUA_ENVIRONMENT)) {
|
||||||
init_env_mt(L);
|
init_env_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_environment_mt(lua_State *L) {
|
||||||
|
lua_push_environment_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,10 +148,7 @@ int li_lua_push_environment(lua_State *L, liEnvironment *env) {
|
|||||||
penv = (liEnvironment**) lua_newuserdata(L, sizeof(liEnvironment*));
|
penv = (liEnvironment**) lua_newuserdata(L, sizeof(liEnvironment*));
|
||||||
*penv = env;
|
*penv = env;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_ENVIRONMENT)) {
|
lua_push_environment_metatable(L);
|
||||||
init_env_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
#include <lighttpd/actions_lua.h>
|
#include <lighttpd/actions_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_FILTER "liFilter*"
|
#define LUA_FILTER "liFilter*"
|
||||||
|
|
||||||
typedef int (*lua_Filter_Attrib)(liFilter *f, lua_State *L);
|
typedef int (*lua_Filter_Attrib)(liFilter *f, lua_State *L);
|
||||||
@ -111,14 +108,18 @@ static const luaL_Reg filter_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_filter_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_filter_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, filter_mt);
|
luaL_register(L, NULL, filter_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_filter_mt(lua_State *L) {
|
static void lua_push_filter_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_FILTER)) {
|
if (li_lua_new_protected_metatable(L, LUA_FILTER)) {
|
||||||
init_filter_mt(L);
|
init_filter_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_filter_mt(lua_State *L) {
|
||||||
|
lua_push_filter_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,10 +146,7 @@ int li_lua_push_filter(lua_State *L, liFilter *f) {
|
|||||||
pf = (liFilter**) lua_newuserdata(L, sizeof(liFilter*));
|
pf = (liFilter**) lua_newuserdata(L, sizeof(liFilter*));
|
||||||
*pf = f;
|
*pf = f;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_FILTER)) {
|
lua_push_filter_metatable(L);
|
||||||
init_filter_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ gboolean li_http_header_tokenizer_next(liHttpHeaderTokenizer *tokenizer, GString
|
|||||||
++pos;
|
++pos;
|
||||||
if (pos >= len) return FALSE; /* no character after backslash */
|
if (pos >= len) return FALSE; /* no character after backslash */
|
||||||
/* append whatever comes */
|
/* append whatever comes */
|
||||||
/* fallthrough */
|
HEDLEY_FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
g_string_append_c(token, str[pos]);
|
g_string_append_c(token, str[pos]);
|
||||||
break;
|
break;
|
||||||
@ -285,7 +285,7 @@ quoted:
|
|||||||
++pos;
|
++pos;
|
||||||
if (pos >= len) return FALSE; /* no character after backslash */
|
if (pos >= len) return FALSE; /* no character after backslash */
|
||||||
/* append whatever comes */
|
/* append whatever comes */
|
||||||
/* fallthrough */
|
HEDLEY_FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
g_string_append_c(token, str[pos]);
|
g_string_append_c(token, str[pos]);
|
||||||
break;
|
break;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_HTTPHEADERS "liHttpHeaders*"
|
#define LUA_HTTPHEADERS "liHttpHeaders*"
|
||||||
|
|
||||||
static int lua_http_headers_get(lua_State *L) {
|
static int lua_http_headers_get(lua_State *L) {
|
||||||
@ -201,14 +198,18 @@ static const luaL_Reg http_headers_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_http_headers_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_http_headers_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, http_headers_mt);
|
luaL_register(L, NULL, http_headers_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_http_headers_mt(lua_State *L) {
|
static void lua_push_http_headers_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_HTTPHEADERS)) {
|
if (li_lua_new_protected_metatable(L, LUA_HTTPHEADERS)) {
|
||||||
init_http_headers_mt(L);
|
init_http_headers_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_http_headers_mt(lua_State *L) {
|
||||||
|
lua_push_http_headers_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,10 +236,7 @@ int li_lua_push_http_headers(lua_State *L, liHttpHeaders *headers) {
|
|||||||
pheaders = (liHttpHeaders**) lua_newuserdata(L, sizeof(liHttpHeaders*));
|
pheaders = (liHttpHeaders**) lua_newuserdata(L, sizeof(liHttpHeaders*));
|
||||||
*pheaders = headers;
|
*pheaders = headers;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_HTTPHEADERS)) {
|
lua_push_http_headers_metatable(L);
|
||||||
init_http_headers_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ gboolean li_log_write_direct(liServer *srv, liWorker *wrk, GString *path, GStrin
|
|||||||
log_entry->queue_link.next = NULL;
|
log_entry->queue_link.next = NULL;
|
||||||
log_entry->queue_link.prev = NULL;
|
log_entry->queue_link.prev = NULL;
|
||||||
|
|
||||||
if (G_LIKELY(wrk)) {
|
if (HEDLEY_LIKELY(wrk)) {
|
||||||
/* push onto local worker log queue */
|
/* push onto local worker log queue */
|
||||||
g_queue_push_tail_link(&wrk->logs.log_queue, &log_entry->queue_link);
|
g_queue_push_tail_link(&wrk->logs.log_queue, &log_entry->queue_link);
|
||||||
} else {
|
} else {
|
||||||
@ -273,7 +273,7 @@ gboolean li_log_write(liServer *srv, liWorker *wrk, liLogContext *context, liLog
|
|||||||
log_entry->queue_link.next = NULL;
|
log_entry->queue_link.next = NULL;
|
||||||
log_entry->queue_link.prev = NULL;
|
log_entry->queue_link.prev = NULL;
|
||||||
|
|
||||||
if (G_LIKELY(wrk)) {
|
if (HEDLEY_LIKELY(wrk)) {
|
||||||
/* push onto local worker log queue */
|
/* push onto local worker log queue */
|
||||||
g_queue_push_tail_link(&wrk->logs.log_queue, &log_entry->queue_link);
|
g_queue_push_tail_link(&wrk->logs.log_queue, &log_entry->queue_link);
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,7 +98,7 @@ liNetworkStatus li_network_read(int fd, liChunkQueue *cq, goffset read_max, liBu
|
|||||||
if (NULL != buffer) {
|
if (NULL != buffer) {
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
/* use last buffer as *buffer; they should be the same anyway */
|
/* use last buffer as *buffer; they should be the same anyway */
|
||||||
if (G_UNLIKELY(buf != *buffer)) {
|
if (HEDLEY_UNLIKELY(buf != *buffer)) {
|
||||||
li_buffer_acquire(buf);
|
li_buffer_acquire(buf);
|
||||||
li_buffer_release(*buffer);
|
li_buffer_release(*buffer);
|
||||||
*buffer = buf;
|
*buffer = buf;
|
||||||
|
@ -240,7 +240,7 @@ void li_pattern_free(liPattern *pattern) {
|
|||||||
part = &g_array_index(arr, liPatternPart, i);
|
part = &g_array_index(arr, liPatternPart, i);
|
||||||
switch (part->type) {
|
switch (part->type) {
|
||||||
case PATTERN_STRING: g_string_free(part->data.str, TRUE); break;
|
case PATTERN_STRING: g_string_free(part->data.str, TRUE); break;
|
||||||
case PATTERN_VAR_ENCODED: /* fall through */
|
case PATTERN_VAR_ENCODED: HEDLEY_FALL_THROUGH;
|
||||||
case PATTERN_VAR: li_condition_lvalue_release(part->data.lvalue); break;
|
case PATTERN_VAR: li_condition_lvalue_release(part->data.lvalue); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ void li_pattern_eval(liVRequest *vr, GString *dest, liPattern *pattern, liPatter
|
|||||||
break;
|
break;
|
||||||
case PATTERN_VAR_ENCODED:
|
case PATTERN_VAR_ENCODED:
|
||||||
encoded = TRUE;
|
encoded = TRUE;
|
||||||
/* fall through */
|
HEDLEY_FALL_THROUGH;
|
||||||
case PATTERN_VAR:
|
case PATTERN_VAR:
|
||||||
if (vr == NULL) continue;
|
if (vr == NULL) continue;
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ void li_pattern_array_cb(GString *pattern_result, guint from, guint to, gpointer
|
|||||||
|
|
||||||
if (NULL == a || 0 == a->len) return;
|
if (NULL == a || 0 == a->len) return;
|
||||||
|
|
||||||
if (G_LIKELY(from <= to)) {
|
if (HEDLEY_LIKELY(from <= to)) {
|
||||||
to = MIN(to, a->len - 1);
|
to = MIN(to, a->len - 1);
|
||||||
for (i = from; i <= to; i++) {
|
for (i = from; i <= to; i++) {
|
||||||
GString *str = g_array_index(a, GString*, i);
|
GString *str = g_array_index(a, GString*, i);
|
||||||
@ -331,7 +331,7 @@ void li_pattern_regex_cb(GString *pattern_result, guint from, guint to, gpointer
|
|||||||
|
|
||||||
if (NULL == match_info) return;
|
if (NULL == match_info) return;
|
||||||
|
|
||||||
if (G_LIKELY(from <= to)) {
|
if (HEDLEY_LIKELY(from <= to)) {
|
||||||
to = MIN(to, G_MAXINT);
|
to = MIN(to, G_MAXINT);
|
||||||
for (i = from; i <= to; i++) {
|
for (i = from; i <= to; i++) {
|
||||||
if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) {
|
if (g_match_info_fetch_pos(match_info, (gint) i, &start_pos, &end_pos)) {
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_PHYSICAL "liPhysical*"
|
#define LUA_PHYSICAL "liPhysical*"
|
||||||
|
|
||||||
typedef int (*lua_Physical_Attrib)(liPhysical *phys, lua_State *L);
|
typedef int (*lua_Physical_Attrib)(liPhysical *phys, lua_State *L);
|
||||||
@ -127,14 +124,18 @@ static const luaL_Reg physical_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_physical_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_physical_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, physical_mt);
|
luaL_register(L, NULL, physical_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_physical_mt(lua_State *L) {
|
static void lua_push_physical_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_PHYSICAL)) {
|
if (li_lua_new_protected_metatable(L, LUA_PHYSICAL)) {
|
||||||
init_physical_mt(L);
|
init_physical_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_physical_mt(lua_State *L) {
|
||||||
|
lua_push_physical_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,10 +162,7 @@ int li_lua_push_physical(lua_State *L, liPhysical *phys) {
|
|||||||
pphys = (liPhysical**) lua_newuserdata(L, sizeof(liPhysical*));
|
pphys = (liPhysical**) lua_newuserdata(L, sizeof(liPhysical*));
|
||||||
*pphys = phys;
|
*pphys = phys;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_PHYSICAL)) {
|
lua_push_physical_metatable(L);
|
||||||
init_physical_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_REQUEST "liRequest*"
|
#define LUA_REQUEST "liRequest*"
|
||||||
#define LUA_REQUESTURI "liRequestUri*"
|
#define LUA_REQUESTURI "liRequestUri*"
|
||||||
|
|
||||||
@ -143,10 +140,16 @@ static const luaL_Reg request_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_request_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_request_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, request_mt);
|
luaL_register(L, NULL, request_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void lua_push_request_metatable(lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_REQUEST)) {
|
||||||
|
init_request_mt(L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef int (*lua_RequestUri_Attrib)(liRequestUri *uri, lua_State *L);
|
typedef int (*lua_RequestUri_Attrib)(liRequestUri *uri, lua_State *L);
|
||||||
|
|
||||||
#define DEF_LUA_MODIFY_GSTRING(attr) \
|
#define DEF_LUA_MODIFY_GSTRING(attr) \
|
||||||
@ -278,19 +281,21 @@ static const luaL_Reg requesturi_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_requesturi_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_requesturi_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, requesturi_mt);
|
luaL_register(L, NULL, requesturi_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_request_mt(lua_State *L) {
|
static void lua_push_requesturi_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_REQUEST)) {
|
if (li_lua_new_protected_metatable(L, LUA_REQUESTURI)) {
|
||||||
init_request_mt(L);
|
|
||||||
}
|
|
||||||
lua_pop(L, 1);
|
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_REQUESTURI)) {
|
|
||||||
init_requesturi_mt(L);
|
init_requesturi_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_request_mt(lua_State *L) {
|
||||||
|
lua_push_request_metatable(L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_push_requesturi_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,10 +322,7 @@ int li_lua_push_request(lua_State *L, liRequest *req) {
|
|||||||
preq = (liRequest**) lua_newuserdata(L, sizeof(liRequest*));
|
preq = (liRequest**) lua_newuserdata(L, sizeof(liRequest*));
|
||||||
*preq = req;
|
*preq = req;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_REQUEST)) {
|
lua_push_request_metatable(L);
|
||||||
init_request_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -348,10 +350,7 @@ int li_lua_push_requesturi(lua_State *L, liRequestUri *uri) {
|
|||||||
puri = (liRequestUri**) lua_newuserdata(L, sizeof(liRequestUri*));
|
puri = (liRequestUri**) lua_newuserdata(L, sizeof(liRequestUri*));
|
||||||
*puri = uri;
|
*puri = uri;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_REQUESTURI)) {
|
lua_push_requesturi_metatable(L);
|
||||||
init_requesturi_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_RESPONSE "liResponse*"
|
#define LUA_RESPONSE "liResponse*"
|
||||||
|
|
||||||
typedef int (*lua_Response_Attrib)(liResponse *resp, lua_State *L);
|
typedef int (*lua_Response_Attrib)(liResponse *resp, lua_State *L);
|
||||||
@ -122,14 +119,18 @@ static const luaL_Reg response_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_response_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_response_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, response_mt);
|
luaL_register(L, NULL, response_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_response_mt(lua_State *L) {
|
static void lua_push_response_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_RESPONSE)) {
|
if (li_lua_new_protected_metatable(L, LUA_RESPONSE)) {
|
||||||
init_response_mt(L);
|
init_response_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_response_mt(lua_State *L) {
|
||||||
|
lua_push_response_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +157,7 @@ int li_lua_push_response(lua_State *L, liResponse *resp) {
|
|||||||
presp = (liResponse**) lua_newuserdata(L, sizeof(liResponse*));
|
presp = (liResponse**) lua_newuserdata(L, sizeof(liResponse*));
|
||||||
*presp = resp;
|
*presp = resp;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_RESPONSE)) {
|
lua_push_response_metatable(L);
|
||||||
init_response_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
|
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* struct stat */
|
/* struct stat */
|
||||||
#define LUA_STAT "struct stat"
|
#define LUA_STAT "struct stat"
|
||||||
|
|
||||||
@ -206,14 +202,18 @@ static const luaL_Reg stat_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_stat_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_stat_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, stat_mt);
|
luaL_register(L, NULL, stat_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_stat_mt(lua_State *L) {
|
static void lua_push_stat_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_STAT)) {
|
if (li_lua_new_protected_metatable(L, LUA_STAT)) {
|
||||||
init_stat_mt(L);
|
init_stat_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_stat_mt(lua_State *L) {
|
||||||
|
lua_push_stat_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,10 +228,7 @@ int li_lua_push_stat(lua_State *L, struct stat *st) {
|
|||||||
pst = (struct stat*) lua_newuserdata(L, sizeof(struct stat));
|
pst = (struct stat*) lua_newuserdata(L, sizeof(struct stat));
|
||||||
*pst = *st;
|
*pst = *st;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_STAT)) {
|
lua_push_stat_metatable(L);
|
||||||
init_stat_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
#include <lighttpd/actions_lua.h>
|
#include <lighttpd/actions_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
typedef struct liSubrequest liSubrequest;
|
typedef struct liSubrequest liSubrequest;
|
||||||
struct liSubrequest {
|
struct liSubrequest {
|
||||||
liWorker *wrk;
|
liWorker *wrk;
|
||||||
@ -156,14 +153,18 @@ static const luaL_Reg subrequest_mt[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void init_subrequest_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_subrequest_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, subrequest_mt);
|
luaL_register(L, NULL, subrequest_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_subrequest_mt(lua_State *L) {
|
static void lua_push_subrequest_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_SUBREQUEST)) {
|
if (li_lua_new_protected_metatable(L, LUA_SUBREQUEST)) {
|
||||||
init_subrequest_mt(L);
|
init_subrequest_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_subrequest_mt(lua_State *L) {
|
||||||
|
lua_push_subrequest_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,10 +191,7 @@ static int li_lua_push_subrequest(lua_State *L, liSubrequest *sr) {
|
|||||||
psr = (liSubrequest**) lua_newuserdata(L, sizeof(liSubrequest*));
|
psr = (liSubrequest**) lua_newuserdata(L, sizeof(liSubrequest*));
|
||||||
*psr = sr;
|
*psr = sr;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_SUBREQUEST)) {
|
lua_push_subrequest_metatable(L);
|
||||||
init_subrequest_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -103,19 +103,19 @@ static void throttle_pool_rearm(liWorker *wrk, liThrottlePool *pool, guint now)
|
|||||||
guint last = g_atomic_int_get((gint*) &pool->last_rearm);
|
guint last = g_atomic_int_get((gint*) &pool->last_rearm);
|
||||||
guint time_diff = now - last;
|
guint time_diff = now - last;
|
||||||
|
|
||||||
if (G_UNLIKELY(time_diff >= LI_THROTTLE_GRANULARITY)) {
|
if (HEDLEY_UNLIKELY(time_diff >= LI_THROTTLE_GRANULARITY)) {
|
||||||
g_mutex_lock(pool->rearm_mutex);
|
g_mutex_lock(pool->rearm_mutex);
|
||||||
/* check again */
|
/* check again */
|
||||||
last = g_atomic_int_get((gint*) &pool->last_rearm);
|
last = g_atomic_int_get((gint*) &pool->last_rearm);
|
||||||
time_diff = now - last;
|
time_diff = now - last;
|
||||||
if (G_LIKELY(time_diff >= LI_THROTTLE_GRANULARITY)) {
|
if (HEDLEY_LIKELY(time_diff >= LI_THROTTLE_GRANULARITY)) {
|
||||||
S_throttle_pool_rearm_workers(pool, wrk->srv->worker_count, time_diff);
|
S_throttle_pool_rearm_workers(pool, wrk->srv->worker_count, time_diff);
|
||||||
g_atomic_int_set((gint*) &pool->last_rearm, now);
|
g_atomic_int_set((gint*) &pool->last_rearm, now);
|
||||||
}
|
}
|
||||||
g_mutex_unlock(pool->rearm_mutex);
|
g_mutex_unlock(pool->rearm_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY(wpool->last_rearm < last)) {
|
if (HEDLEY_UNLIKELY(wpool->last_rearm < last)) {
|
||||||
/* distribute wpool->magazine */
|
/* distribute wpool->magazine */
|
||||||
GList *lnk;
|
GList *lnk;
|
||||||
guint connections = wpool->connections;
|
guint connections = wpool->connections;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <lighttpd/actions_lua.h>
|
#include <lighttpd/actions_lua.h>
|
||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_KVLIST_VALUE "li KeyValue list (string, liValue*)"
|
#define LUA_KVLIST_VALUE "li KeyValue list (string, liValue*)"
|
||||||
|
|
||||||
static int lua_kvlist_index(lua_State *L) {
|
static int lua_kvlist_index(lua_State *L) {
|
||||||
@ -57,13 +55,21 @@ fail:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lua_push_kvlist_metatable(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_kvlist_mt(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_KVLIST_VALUE)) {
|
|
||||||
lua_pushcclosure(L, lua_kvlist_index, 0);
|
lua_pushcclosure(L, lua_kvlist_index, 0);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_kvlist_metatable(lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_KVLIST_VALUE)) {
|
||||||
|
init_kvlist_mt(L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void li_lua_init_value_mt(lua_State *L) {
|
||||||
|
lua_push_kvlist_metatable(L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static liValue* li_value_from_lua_table(liServer *srv, lua_State *L, int ndx) {
|
static liValue* li_value_from_lua_table(liServer *srv, lua_State *L, int ndx) {
|
||||||
liValue *val, *entry;
|
liValue *val, *entry;
|
||||||
@ -107,7 +113,7 @@ static liValue* li_value_from_lua_table(liServer *srv, lua_State *L, int ndx) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR(srv, "Unexpted key type in table: %s (%i) - skipping entry", lua_typename(L, lua_type(L, -1)), lua_type(L, -1));
|
ERROR(srv, "Unexpected key type in table: %s (%i) - skipping entry", lua_typename(L, lua_type(L, -1)), lua_type(L, -1));
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
#include <lighttpd/core_lua.h>
|
#include <lighttpd/core_lua.h>
|
||||||
#include <lighttpd/actions_lua.h>
|
#include <lighttpd/actions_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#define LUA_VREQUEST "liVRequest*"
|
#define LUA_VREQUEST "liVRequest*"
|
||||||
|
|
||||||
typedef int (*lua_VRequest_Attrib)(liVRequest *vr, lua_State *L);
|
typedef int (*lua_VRequest_Attrib)(liVRequest *vr, lua_State *L);
|
||||||
@ -340,15 +337,14 @@ static const luaL_Reg vrequest_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_vrequest_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_vrequest_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, vrequest_mt);
|
luaL_register(L, NULL, vrequest_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_vrequest_mt(lua_State *L) {
|
static void lua_push_vrequest_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_VREQUEST)) {
|
if (li_lua_new_protected_metatable(L, LUA_VREQUEST)) {
|
||||||
init_vrequest_mt(L);
|
init_vrequest_mt(L);
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
liVRequest* li_lua_get_vrequest(lua_State *L, int ndx) {
|
liVRequest* li_lua_get_vrequest(lua_State *L, int ndx) {
|
||||||
@ -374,10 +370,7 @@ int li_lua_push_vrequest(lua_State *L, liVRequest *vr) {
|
|||||||
pvr = (liVRequest**) lua_newuserdata(L, sizeof(liVRequest*));
|
pvr = (liVRequest**) lua_newuserdata(L, sizeof(liVRequest*));
|
||||||
*pvr = vr;
|
*pvr = vr;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_VREQUEST)) {
|
lua_push_vrequest_metatable(L);
|
||||||
init_vrequest_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -492,14 +485,21 @@ static const luaL_Reg coninfo_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_coninfo_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_coninfo_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, coninfo_mt);
|
luaL_register(L, NULL, coninfo_mt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void li_lua_init_coninfo_mt(lua_State *L) {
|
static void lua_push_coninfo_metatable(lua_State *L) {
|
||||||
if (luaL_newmetatable(L, LUA_CONINFO)) {
|
if (li_lua_new_protected_metatable(L, LUA_CONINFO)) {
|
||||||
init_coninfo_mt(L);
|
init_coninfo_mt(L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void li_lua_init_virtualrequest_mt(lua_State *L) {
|
||||||
|
lua_push_vrequest_metatable(L);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_push_coninfo_metatable(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,10 +526,7 @@ int li_lua_push_coninfo(lua_State *L, liConInfo *coninfo) {
|
|||||||
pconinfo = (liConInfo**) lua_newuserdata(L, sizeof(liConInfo*));
|
pconinfo = (liConInfo**) lua_newuserdata(L, sizeof(liConInfo*));
|
||||||
*pconinfo = coninfo;
|
*pconinfo = coninfo;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_CONINFO)) {
|
lua_push_coninfo_metatable(L);
|
||||||
init_coninfo_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ enum FCGI_Type {
|
|||||||
|
|
||||||
enum FCGI_Flags {
|
enum FCGI_Flags {
|
||||||
FCGI_KEEP_CONN = 1
|
FCGI_KEEP_CONN = 1
|
||||||
};
|
} HEDLEY_FLAGS;
|
||||||
|
|
||||||
enum FCGI_Role {
|
enum FCGI_Role {
|
||||||
FCGI_RESPONDER = 1,
|
FCGI_RESPONDER = 1,
|
||||||
|
@ -314,7 +314,7 @@ static void do_gnutls_read(liGnuTLSFilter *f) {
|
|||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
/* use last buffer as raw_in_buffer; they should be the same anyway */
|
/* use last buffer as raw_in_buffer; they should be the same anyway */
|
||||||
if (G_UNLIKELY(buf != f->raw_in_buffer)) {
|
if (HEDLEY_UNLIKELY(buf != f->raw_in_buffer)) {
|
||||||
li_buffer_acquire(buf);
|
li_buffer_acquire(buf);
|
||||||
li_buffer_release(f->raw_in_buffer);
|
li_buffer_release(f->raw_in_buffer);
|
||||||
f->raw_in_buffer = buf;
|
f->raw_in_buffer = buf;
|
||||||
@ -427,7 +427,7 @@ static void do_gnutls_write(liGnuTLSFilter *f) {
|
|||||||
_ERROR(f->srv, f->wrk, f->log_context, "Couldn't read data from chunkqueue: %s", err->message);
|
_ERROR(f->srv, f->wrk, f->log_context, "Couldn't read data from chunkqueue: %s", err->message);
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
}
|
}
|
||||||
/* fall through */
|
HEDLEY_FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
f_abort_gnutls(f);
|
f_abort_gnutls(f);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
#include <lighttpd/value_lua.h>
|
#include <lighttpd/value_lua.h>
|
||||||
#include <lighttpd/actions_lua.h>
|
#include <lighttpd/actions_lua.h>
|
||||||
|
|
||||||
#include <lualib.h>
|
|
||||||
#include <lauxlib.h>
|
|
||||||
|
|
||||||
#ifndef DEFAULT_LUADIR
|
#ifndef DEFAULT_LUADIR
|
||||||
#define DEFAULT_LUADIR "/usr/local/share/lighttpd2/lua"
|
#define DEFAULT_LUADIR "/usr/local/share/lighttpd2/lua"
|
||||||
#endif
|
#endif
|
||||||
@ -186,9 +183,9 @@ static liAction* lua_handler_create(liServer *srv, liWorker *wrk, liPlugin* p, l
|
|||||||
v_filename = val;
|
v_filename = val;
|
||||||
} else if (LI_VALUE_LIST == li_value_type(val)) {
|
} else if (LI_VALUE_LIST == li_value_type(val)) {
|
||||||
switch (li_value_list_len(val)) {
|
switch (li_value_list_len(val)) {
|
||||||
case 3: v_args = li_value_list_at(val, 2); /* fall through */
|
case 3: v_args = li_value_list_at(val, 2); HEDLEY_FALL_THROUGH;
|
||||||
case 2: v_options = li_value_list_at(val, 1); /* fall through */
|
case 2: v_options = li_value_list_at(val, 1); HEDLEY_FALL_THROUGH;
|
||||||
case 1: v_filename = li_value_list_at(val, 0); /* fall through */
|
case 1: v_filename = li_value_list_at(val, 0); HEDLEY_FALL_THROUGH;
|
||||||
case 0: break;
|
case 0: break;
|
||||||
default:
|
default:
|
||||||
ERROR(srv, "%s", "lua.handler expects at most 3 arguments");
|
ERROR(srv, "%s", "lua.handler expects at most 3 arguments");
|
||||||
@ -525,9 +522,9 @@ static gboolean lua_plugin(liServer *srv, liPlugin *p, liValue *val, gpointer us
|
|||||||
v_filename = val;
|
v_filename = val;
|
||||||
} else if (LI_VALUE_LIST == li_value_type(val)) {
|
} else if (LI_VALUE_LIST == li_value_type(val)) {
|
||||||
switch (li_value_list_len(val)) {
|
switch (li_value_list_len(val)) {
|
||||||
case 3: v_args = li_value_list_at(val, 2); /* fall through */
|
case 3: v_args = li_value_list_at(val, 2); HEDLEY_FALL_THROUGH;
|
||||||
case 2: v_options = li_value_list_at(val, 1); /* fall through */
|
case 2: v_options = li_value_list_at(val, 1); HEDLEY_FALL_THROUGH;
|
||||||
case 1: v_filename = li_value_list_at(val, 0); /* fall through */
|
case 1: v_filename = li_value_list_at(val, 0); HEDLEY_FALL_THROUGH;
|
||||||
case 0: break;
|
case 0: break;
|
||||||
default:
|
default:
|
||||||
ERROR(srv, "%s", "lua.plugin expects at most 3 arguments");
|
ERROR(srv, "%s", "lua.plugin expects at most 3 arguments");
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_LUA_H
|
#ifdef HAVE_LUA_H
|
||||||
# include <lighttpd/core_lua.h>
|
# include <lighttpd/core_lua.h>
|
||||||
# include <lualib.h>
|
|
||||||
# include <lauxlib.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LI_API gboolean mod_memcached_init(liModules *mods, liModule *mod);
|
LI_API gboolean mod_memcached_init(liModules *mods, liModule *mod);
|
||||||
@ -913,6 +911,18 @@ static const luaL_Reg mc_con_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static HEDLEY_NEVER_INLINE void init_mc_con_mt(lua_State *L) {
|
||||||
|
luaL_register(L, NULL, mc_con_mt);
|
||||||
|
lua_pushvalue(L, -1);
|
||||||
|
lua_setfield(L, -2, "__index");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lua_push_mc_con_metatable(lua_State *L) {
|
||||||
|
if (li_lua_new_protected_metatable(L, LUA_MEMCACHEDCON)) {
|
||||||
|
init_mc_con_mt(L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef int (*lua_mc_req_Attrib)(mc_lua_request *req, lua_State *L);
|
typedef int (*lua_mc_req_Attrib)(mc_lua_request *req, lua_State *L);
|
||||||
|
|
||||||
static int lua_mc_req_attr_read_response(mc_lua_request *req, lua_State *L) {
|
static int lua_mc_req_attr_read_response(mc_lua_request *req, lua_State *L) {
|
||||||
@ -980,14 +990,14 @@ static const luaL_Reg mc_req_mt[] = {
|
|||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void init_mc_con_mt(lua_State *L) {
|
static HEDLEY_NEVER_INLINE void init_mc_req_mt(lua_State *L) {
|
||||||
luaL_register(L, NULL, mc_con_mt);
|
luaL_register(L, NULL, mc_req_mt);
|
||||||
lua_pushvalue(L, -1);
|
|
||||||
lua_setfield(L, -2, "__index");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_mc_req_mt(lua_State *L) {
|
static void lua_push_mc_req_metatable(lua_State *L) {
|
||||||
luaL_register(L, NULL, mc_req_mt);
|
if (li_lua_new_protected_metatable(L, LUA_MEMCACHEDREQUEST)) {
|
||||||
|
init_mc_req_mt(L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static liMemcachedCon* li_lua_get_memcached_con(lua_State *L, int ndx) {
|
static liMemcachedCon* li_lua_get_memcached_con(lua_State *L, int ndx) {
|
||||||
@ -1021,10 +1031,7 @@ static int li_lua_push_memcached_con(lua_State *L, liMemcachedCon *con) {
|
|||||||
pcon = (liMemcachedCon**) lua_newuserdata(L, sizeof(liMemcachedCon*));
|
pcon = (liMemcachedCon**) lua_newuserdata(L, sizeof(liMemcachedCon*));
|
||||||
*pcon = con;
|
*pcon = con;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_MEMCACHEDCON)) {
|
lua_push_mc_con_metatable(L);
|
||||||
init_mc_con_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1072,10 +1079,7 @@ static int li_lua_push_memcached_req(lua_State *L, mc_lua_request *req) {
|
|||||||
preq = (mc_lua_request**) lua_newuserdata(L, sizeof(mc_lua_request*));
|
preq = (mc_lua_request**) lua_newuserdata(L, sizeof(mc_lua_request*));
|
||||||
*preq = req;
|
*preq = req;
|
||||||
|
|
||||||
if (luaL_newmetatable(L, LUA_MEMCACHEDREQUEST)) {
|
lua_push_mc_req_metatable(L);
|
||||||
init_mc_req_mt(L);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1121,8 +1125,10 @@ static void mod_memcached_lua_init(liLuaState *LL, liServer *srv, liWorker *wrk,
|
|||||||
|
|
||||||
if (wrk) {
|
if (wrk) {
|
||||||
li_lua_lock(LL);
|
li_lua_lock(LL);
|
||||||
|
/* memcached global table */
|
||||||
lua_newtable(L); /* { } */
|
lua_newtable(L); /* { } */
|
||||||
|
|
||||||
|
/* memcached.new */
|
||||||
lua_pushlightuserdata(L, wrk);
|
lua_pushlightuserdata(L, wrk);
|
||||||
lua_pushcclosure(L, mc_lua_new, 1);
|
lua_pushcclosure(L, mc_lua_new, 1);
|
||||||
lua_setfield(L, -2, "new");
|
lua_setfield(L, -2, "new");
|
||||||
|
@ -55,7 +55,7 @@ enum {
|
|||||||
SE_CLIENT_CERT = 0x2,
|
SE_CLIENT_CERT = 0x2,
|
||||||
SE_SERVER = 0x4,
|
SE_SERVER = 0x4,
|
||||||
SE_SERVER_CERT = 0x8
|
SE_SERVER_CERT = 0x8
|
||||||
};
|
} HEDLEY_FLAGS;
|
||||||
|
|
||||||
static openssl_context* mod_openssl_context_new(void) {
|
static openssl_context* mod_openssl_context_new(void) {
|
||||||
openssl_context *ctx = g_slice_new0(openssl_context);
|
openssl_context *ctx = g_slice_new0(openssl_context);
|
||||||
|
@ -431,7 +431,7 @@ static void do_ssl_read(liOpenSSLFilter *f) {
|
|||||||
|
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
/* use last buffer as raw_in_buffer; they should be the same anyway */
|
/* use last buffer as raw_in_buffer; they should be the same anyway */
|
||||||
if (G_UNLIKELY(buf != f->raw_in_buffer)) {
|
if (HEDLEY_UNLIKELY(buf != f->raw_in_buffer)) {
|
||||||
li_buffer_acquire(buf);
|
li_buffer_acquire(buf);
|
||||||
li_buffer_release(f->raw_in_buffer);
|
li_buffer_release(f->raw_in_buffer);
|
||||||
f->raw_in_buffer = buf;
|
f->raw_in_buffer = buf;
|
||||||
@ -544,7 +544,7 @@ static void do_ssl_write(liOpenSSLFilter *f) {
|
|||||||
_ERROR(f->srv, f->wrk, f->log_context, "Couldn't read data from chunkqueue: %s", err->message);
|
_ERROR(f->srv, f->wrk, f->log_context, "Couldn't read data from chunkqueue: %s", err->message);
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
}
|
}
|
||||||
/* fall through */
|
HEDLEY_FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
f_abort_ssl(f);
|
f_abort_ssl(f);
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user