File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ struct bio_job {
8484};
8585
8686void * bioProcessBackgroundJobs (void * arg );
87+ void lazyfreeFreeObjectFromBioThread (robj * o );
8788
8889/* Make sure we have enough stack to perform all the things we do in the
8990 * main thread. */
@@ -186,7 +187,7 @@ void *bioProcessBackgroundJobs(void *arg) {
186187 } else if (type == BIO_AOF_FSYNC ) {
187188 aof_fsync ((long )job -> arg1 );
188189 } else if (type == BIO_LAZY_FREE ) {
189- decrRefCount (( robj * ) job -> arg1 );
190+ lazyfreeFreeObjectFromBioThread ( job -> arg1 );
190191 } else {
191192 serverPanic ("Wrong job type in bioProcessBackgroundJobs()." );
192193 }
Original file line number Diff line number Diff line change 11#include "server.h"
22#include "bio.h"
3+ #include "atomicvar.h"
34
45static size_t lazyfree_objects = 0 ;
5- static size_t lazyfree_dbs = 0 ;
66pthread_mutex_t lazyfree_objects_mutex = PTHREAD_MUTEX_INITIALIZER ;
7- pthread_mutex_t lazyfree_objects_dbs = PTHREAD_MUTEX_INITIALIZER ;
87
98/* Return the amount of work needed in order to free an object.
109 * The return value is not always the actual number of allocations the
@@ -60,6 +59,7 @@ int dbAsyncDelete(redisDb *db, robj *key) {
6059 /* If releasing the object is too much work, let's put it into the
6160 * lazy free list. */
6261 if (free_effort > LAZYFREE_THRESHOLD ) {
62+ atomicIncr (lazyfree_objects ,1 ,& lazyfree_objects_mutex );
6363 bioCreateBackgroundJob (BIO_LAZY_FREE ,val ,NULL ,NULL );
6464 dictSetVal (db -> dict ,de ,NULL );
6565 }
@@ -74,3 +74,10 @@ int dbAsyncDelete(redisDb *db, robj *key) {
7474 return 0 ;
7575 }
7676}
77+
78+ /* Implementation of function to release a single object called from the
79+ * lazyfree thread from bio.c. */
80+ void lazyfreeFreeObjectFromBioThread (robj * o ) {
81+ decrRefCount (o );
82+ atomicDecr (lazyfree_objects ,1 ,& lazyfree_objects_mutex );
83+ }
You can’t perform that action at this time.
0 commit comments