QDEL_IN harddel prevention (#60937) (#7669)

QDEL_IN could hardel if the timer was greater than 5 minutes (time for the qdel queue)

we can use weakref to prevent this

Co-authored-by: BraveMole <bsouchu@gmail.com>
This commit is contained in:
SkyratBot
2021-08-21 16:16:26 +02:00
committed by GitHub
parent 9bc87fdef4
commit 5c95967cad
4 changed files with 7 additions and 3 deletions

View File

@@ -35,6 +35,10 @@
#define GC_QUEUED_FOR_QUEUING -1
#define GC_CURRENTLY_BEING_QDELETED -2
// Defines for the time left for an item to get its reference cleaned
#define GC_FILTER_QUEUE 5 MINUTES
#define GC_DEL_QUEUE 10 SECONDS
#define QDELING(X) (X.gc_destroyed)
#define QDELETED(X) (!X || QDELING(X))
#define QDESTROYING(X) (!X || X.gc_destroyed == GC_CURRENTLY_BEING_QDELETED)

View File

@@ -1,4 +1,4 @@
#define QDEL_IN(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE)
#define QDEL_IN(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, time > GC_FILTER_QUEUE ? WEAKREF(item) : item), time, TIMER_STOPPABLE)
#define QDEL_IN_CLIENT_TIME(item, time) addtimer(CALLBACK(GLOBAL_PROC, .proc/qdel, item), time, TIMER_STOPPABLE | TIMER_CLIENT_TIME)
#define QDEL_NULL(item) qdel(item); item = null
#define QDEL_LIST(L) if(L) { for(var/I in L) qdel(I); L.Cut(); }

View File

@@ -29,7 +29,7 @@ SUBSYSTEM_DEF(garbage)
runlevels = RUNLEVELS_DEFAULT | RUNLEVEL_LOBBY
init_order = INIT_ORDER_GARBAGE
var/list/collection_timeout = list(5 MINUTES, 10 SECONDS) // deciseconds to wait before moving something up in the queue to the next level
var/list/collection_timeout = list(GC_FILTER_QUEUE, GC_DEL_QUEUE) // deciseconds to wait before moving something up in the queue to the next level
//Stat tracking
var/delslasttick = 0 // number of del()'s we've done this tick

View File

@@ -87,7 +87,7 @@
add_overlay("hatch")
add_overlay("legs_retracted")
addtimer(CALLBACK(src, .proc/startUp), 50)
QDEL_IN(WEAKREF(src), 8 MINUTES) //Self-destruct after 8 min
QDEL_IN(src, 8 MINUTES) //Self-destruct after 8 min
SSeconomy.market_crashing = TRUE