/* If named defaults were preserved, ensure <def_ref> count is resetted. */
if (!(global.tune.options & GTUNE_PURGE_DEFAULTS))
defaults_px_unref_all();
- /* All proxies are removed now, so every defaults should also be freed
- * when their <def_ref> count reached zero.
- */
- BUG_ON(!LIST_ISEMPTY(&defaults_list));
userlist_free(userlist);
list_for_each_entry(pdf, &post_deinit_list, list)
pdf->fct();
+ /* All proxies are removed now, so every defaults should also be freed
+ * when their <def_ref> count reached zero.
+ */
+ BUG_ON(!LIST_ISEMPTY(&defaults_list));
+
ha_free(&global.log_send_hostname);
chunk_destroy(&global.log_tag);
ha_free(&global.chroot);
lua_setmetatable(L, -2);
}
+int hlua_proxy_gc(lua_State *L)
+{
+ struct proxy *px = hlua_checkudata(L, 1, class_proxy_ref);
+ proxy_drop(px);
+ return 0;
+}
+
static struct proxy *hlua_check_proxy(lua_State *L, int ud)
{
- return hlua_checkudata(L, ud, class_proxy_ref);
+ struct proxy *px = hlua_checkudata(L, ud, class_proxy_ref);
+ if (px->flags & PR_FL_DELETED)
+ return NULL;
+ return px;
}
int hlua_proxy_get_name(lua_State *L)
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
lua_pushstring(L, px->id);
return 1;
}
char buffer[17];
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
snprintf(buffer, sizeof(buffer), "%d", px->uuid);
lua_pushstring(L, buffer);
return 1;
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL)
+ return 0;
+
/* safe to call without PROXY_LOCK - pause_proxy takes it */
pause_proxy(px);
return 0;
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL)
+ return 0;
+
/* safe to call without PROXY_LOCK - resume_proxy takes it */
resume_proxy(px);
return 0;
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL)
+ return 0;
+
/* safe to call without PROXY_LOCK - stop_proxy takes it */
stop_proxy(px);
return 0;
const char *str;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
str = proxy_cap_str(px->cap);
lua_pushstring(L, str);
return 1;
int i;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
if (px->cap & PR_CAP_BE)
stats_fill_be_line(px, STAT_F_SHLGNDS, stats, STATS_LEN, NULL);
else
const char *str;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
str = proxy_mode_str(px->mode);
lua_pushstring(L, str);
return 1;
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL)
+ return 0;
+
srv_shutdown_backup_streams(px, SF_ERR_KILLED);
return 0;
}
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
lua_pushinteger(L, px->srv_act);
return 1;
}
struct proxy *px;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
+
lua_pushinteger(L, px->srv_bck);
return 1;
}
struct mailer *mailer;
px = hlua_check_proxy(L, 1);
+ if (px == NULL) {
+ lua_pushnil(L);
+ return 0;
+ }
if (!px->email_alert.mailers.m)
return 0; /* email-alert mailers not found on proxy */
lua_pushlightuserdata(L, px);
lua_rawseti(L, -2, 0);
+ proxy_take(px);
+
/* set public methods */
hlua_class_function(L, "get_name", hlua_proxy_get_name);
hlua_class_function(L, "get_uuid", hlua_proxy_get_uuid);
/* Create proxy object. */
lua_newtable(L);
+ hlua_class_function(L, "__gc", hlua_proxy_gc);
hlua_class_function(L, "__index", hlua_proxy_index);
class_proxy_ref = hlua_register_metatable(L, CLASS_PROXY);