From d0ef45acc3f75f86c8533e6285af4a9e042b0e35 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Tue, 25 Feb 2020 09:38:17 +0100 Subject: [PATCH] initialize free lists when starting dbChannel --- modules/database/src/ioc/db/dbChannel.c | 1 + modules/database/src/ioc/db/dbEvent.c | 27 ++++++++++++++++++------- modules/database/src/ioc/db/dbEvent.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/modules/database/src/ioc/db/dbChannel.c b/modules/database/src/ioc/db/dbChannel.c index 032293bc5..34a3de45f 100644 --- a/modules/database/src/ioc/db/dbChannel.c +++ b/modules/database/src/ioc/db/dbChannel.c @@ -68,6 +68,7 @@ void dbChannelInit (void) freeListInitPvt(&dbChannelFreeList, sizeof(dbChannel), 128); freeListInitPvt(&chFilterFreeList, sizeof(chFilter), 64); freeListInitPvt(&dbchStringFreeList, sizeof(epicsOldString), 128); + db_init_event_freelists(); } static void chf_value(parseContext *parser, parse_result *presult) diff --git a/modules/database/src/ioc/db/dbEvent.c b/modules/database/src/ioc/db/dbEvent.c index 4b3caac9d..437cb6d5d 100644 --- a/modules/database/src/ioc/db/dbEvent.c +++ b/modules/database/src/ioc/db/dbEvent.c @@ -252,18 +252,15 @@ int dbel ( const char *pname, unsigned level ) } /* - * DB_INIT_EVENTS() + * DB_INIT_EVENT_FREELISTS() * * - * Initialize the event facility for this task. Must be called at least once - * by each task which uses the db event facility + * Initialize the free lists used by the event facility. + * Safe to be called multiple times. * - * returns: ptr to event user block or NULL if memory can't be allocated */ -dbEventCtx db_init_events (void) +void db_init_event_freelists (void) { - struct event_user * evUser; - if (!dbevEventUserFreeList) { freeListInitPvt(&dbevEventUserFreeList, sizeof(struct event_user),8); @@ -280,6 +277,22 @@ dbEventCtx db_init_events (void) freeListInitPvt(&dbevFieldLogFreeList, sizeof(struct db_field_log),2048); } +} + +/* + * DB_INIT_EVENTS() + * + * + * Initialize the event facility for this task. Must be called at least once + * by each task which uses the db event facility + * + * returns: ptr to event user block or NULL if memory can't be allocated + */ +dbEventCtx db_init_events (void) +{ + struct event_user * evUser; + + db_init_event_freelists(); evUser = (struct event_user *) freeListCalloc(dbevEventUserFreeList); diff --git a/modules/database/src/ioc/db/dbEvent.h b/modules/database/src/ioc/db/dbEvent.h index c8254800b..d7ebdf805 100644 --- a/modules/database/src/ioc/db/dbEvent.h +++ b/modules/database/src/ioc/db/dbEvent.h @@ -51,6 +51,7 @@ epicsShareFunc int db_post_events ( typedef void * dbEventCtx; typedef void EXTRALABORFUNC (void *extralabor_arg); +void db_init_event_freelists (void); epicsShareFunc dbEventCtx db_init_events (void); epicsShareFunc int db_start_events ( dbEventCtx ctx, const char *taskname, void (*init_func)(void *),