Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
lxrc.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Application Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: lxrc.h 6657 2026-10-28 18:19:39Z wini $
15 *
16 * COPYRIGHT: Real Time Logic, 2023 - 2026
17 * https://realtimelogic.com
18 *
19 * The copyright to the program herein is the property of
20 * Real Time Logic. The program may be used or copied only
21 * with the written permission from Real Time Logic or
22 * in accordance with the terms and conditions stipulated in
23 * the agreement under which the program has been supplied.
24 ****************************************************************************
25 *
26 *
27 */
30#ifndef __lxrc_h
31#define __lxrc_h
32
33#include <TargConfig.h>
34
35#if BA_ENABLE_SHARKSSL
36#include <SharkSSL.h>
37#endif
38#include <balua.h>
39#include <SoDispCon.h>
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
58BA_API void balua_forkpty(lua_State* L);
59
63BA_API void balua_http(lua_State* L);
64
68BA_API void balua_luaio(lua_State *L);
69
73BA_API void balua_sharkssl(lua_State *L);
74
78BA_API void balua_socket(lua_State* L);
79
86BA_API void balua_relsocket(lua_State* L);
87
91BA_API void balua_crypto(lua_State *L);
92
93struct ThreadJob;
94struct LThreadMgr;
95
101BA_API void balua_tracelogger(lua_State *L, struct LThreadMgr* tmgr);
102
120typedef void (*ThreadJob_Run)(struct ThreadJob* tj, struct LThreadMgr* mgr);
121
132typedef void (*ThreadJob_LRun)(
133 struct ThreadJob* tj, int msgh, struct LThreadMgr* mgr);
134
147typedef struct LThreadMgr
148{
149 HttpCmdThreadPoolIntf super; /* Inherits from HttpCmdThreadPoolIntf */
150 DoubleList idleThreadList;
151 DoubleList runningThreadList;
152 DoubleList pendingJobList; /* ThreadJob */
154 lua_State* Lg;
158 ThreadPriority priority;
159 int stackSize;
162
163
172typedef struct ThreadJob
173{
174 DoubleLink super; /* Inherits from DoubleLink */
175 ThreadJob_Run run;
176 ThreadJob_LRun lrun;
177 lua_State* Lt;
179
186#define LThreadMgr_canRun(o) ! DoubleList_isEmpty(&(o)->idleThreadList)
187
195#define LThreadMgr_enableHttpPool(o, server) \
196 HttpServer_setThreadPoolIntf(server, (HttpCmdThreadPoolIntf*)o)
197
205
220 ThreadPriority priority, int stackSize,
221 int threads, lua_State* L, int allowCreate);
222
232BA_API ThreadJob* ThreadJob_create(size_t size, ThreadJob_Run run);
233
243BA_API ThreadJob* ThreadJob_lcreate(size_t size, ThreadJob_LRun lrun);
244
255 /* end of ThreadMgr */
257 /* end of AuxLSP */
259
260#ifdef __cplusplus
261}
262#endif
263
264/************************ Private functions ***************************/
265
266int lGetStdSockOptions(lua_State* L, int tabIx, const char** intf,
267 BaBool* ipv6, BaBool* secure);
268#if BA_ENABLE_SHARKSSL
269void lsharkssl_unlock(lua_State *L,SharkSsl* super);
270SharkSsl* lsharkssl_lock(
271 lua_State *L,int tabIx,SharkSsl_Role role,SharkSsl* lockedShark);
272#endif
273int pushCertificate(lua_State *L, SoDispCon* con);
274int pushCiphers(lua_State *L, SoDispCon* con);
275int calcTabSize(lua_State* L, int ix, BaBool query); /* lhttp.c */
276struct HttpClientKeyVal;
277char* extractTab(const char* tab, lua_State* L, int ix,
278 char* ud, struct HttpClientKeyVal** pkv); /* lhttp.c */
279
280#define HTTPCLIENT "HTTPCLIENT"
281struct HttpClient;
282#define toHttpClient(L,ix) (struct HttpClient*)luaL_checkudata(L,ix,HTTPCLIENT)
283
284#define BACERTSTORE "BACERTSTORE"
285/* tocs: To SharkSslCertStore -- Certificate Authority
286 */
287#define toCertStore(L,ix) (SharkSslCertStore*)luaL_checkudata(L,ix,BACERTSTORE)
288
289
290
291#endif
BA_API void balua_relsocket(lua_State *L)
Notify registered coroutine sockets that the server is shutting down.
BA_API void balua_crypto(lua_State *L)
Install the crypto Lua bindings.
BA_API void balua_tracelogger(lua_State *L, struct LThreadMgr *tmgr)
Install the TraceLogger Lua bindings.
BA_API void balua_luaio(lua_State *L)
Install the LuaIo Lua bindings.
BA_API void balua_sharkssl(lua_State *L)
Install the SharkSSL Lua bindings.
BA_API void balua_socket(lua_State *L)
Install the socket Lua bindings.
BA_API void balua_http(lua_State *L)
Install the httpc Lua bindings.
BA_API void balua_forkpty(lua_State *L)
Install the forkpty Lua bindings.
ThreadPriority
Portable priority choices, mapped to the target operating system.
Definition: ThreadLib.h:61
BA_API ThreadJob * ThreadJob_lcreate(size_t size, ThreadJob_LRun lrun)
Create a thread job designed to execute Lua code.
void(* ThreadJob_Run)(struct ThreadJob *tj, struct LThreadMgr *mgr)
Generic ThreadJob callback.
Definition: lxrc.h:120
struct ThreadJob ThreadJob
An owned unit of work created by ThreadJob_create or ThreadJob_lcreate.
BA_API void LThreadMgr_constructor(LThreadMgr *o, HttpServer *server, ThreadPriority priority, int stackSize, int threads, lua_State *L, int allowCreate)
Initialize the thread pool and install ba.thread.
BA_API int LThreadMgr_run(LThreadMgr *o, ThreadJob *tj)
This function sends a thread job to an available idle thread, or queues the job if no threads are cur...
struct LThreadMgr LThreadMgr
Run native jobs and protected Lua callbacks on BAS worker threads.
BA_API void LThreadMgr_destructor(LThreadMgr *o)
This function terminates the Thread Pool and waits for all threads to stop before returning.
BA_API ThreadJob * ThreadJob_create(size_t size, ThreadJob_Run run)
Create a generic thread job.
void(* ThreadJob_LRun)(struct ThreadJob *tj, int msgh, struct LThreadMgr *mgr)
ThreadJob callback designed for calling Lua code using lua_pcall.
Definition: lxrc.h:132
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:121
A container for key/value pairs used when setting custom HTTP headers or URL encoded HTTP parameters.
Definition: HttpClient.h:90
Blocking HTTP/1.1 client with optional SharkSSL HTTPS support.
Definition: HttpClient.h:187
Worker-pool dispatch interface borrowed by HttpServer.
Definition: HttpCmdThreadPoolIntf.h:63
Route and process HTTP requests using a borrowed dispatcher.
Definition: HttpServer.h:3463
Run native jobs and protected Lua callbacks on BAS worker threads.
Definition: lxrc.h:148
lua_State * Lg
Global state.
Definition: lxrc.h:154
int runningThreads
Threads currently running.
Definition: lxrc.h:155
int pendingJobs
Jobs queued.
Definition: lxrc.h:156
HttpServer * server
The server object.
Definition: lxrc.h:153
int isDynamic
if created via ba.thread.create()
Definition: lxrc.h:157
int threads
number of threads
Definition: lxrc.h:160
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
An owned unit of work created by ThreadJob_create or ThreadJob_lcreate.
Definition: lxrc.h:173
lua_State * Lt
Borrowed Lua thread, valid only during the job callback.
Definition: lxrc.h:177