0522 core: import NSS asyncio control pool runtime

This commit is contained in:
Mario Fetka
2026-06-14 09:05:06 +00:00
parent 41cf615b5c
commit 77d4e1df7b
7 changed files with 299 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) Initialization module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Definitions used by caching.
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _NCACHE_H_
#define _NCACHE_H_
#ifndef _XCACHE_H_
# include <include/xCache.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*-------------------------------------------------------------------------
* Initialization routines
*-------------------------------------------------------------------------*/
extern STATUS CACHE_Startup(void);
extern void CACHE_Shutdown(void);
extern STATUS fsmStart(void);
extern void fsmStop(void);
extern STATUS SLAB_Startup(void);
extern void SLAB_Shutdown(void);
extern STATUS MSG_Startup(void);
extern void MSG_Shutdown(void);
extern STATUS BOND_Startup(void);
extern void BOND_Shutdown(void);
extern STATUS ASYNCIO_Startup(void);
extern void ASYNCIO_Shutdown(void);
extern STATUS WORK_Startup(void);
extern void WORK_Shutdown(void);
/*-------------------------------------------------------------------------
* Macros for translating INTERNAL names to EXTERNAL names
*-------------------------------------------------------------------------*/
#define defaultSignal LB_defaultSignal
#define defaultFlush(a1) LB_defaultFlush(a1)
#define defaultFlushWait(a1) LB_defaultFlushWait(a1)
#define lazyFlush(a1) LB_lazyFlush(a1)
#define continueFlush(f1) LB_continueFlush(f1)
#define initBind(p1,p2,p3) LB_initBind(p1,p2,p3)
#define bind(p1,p2) LB_bind(p1,p2)
#define freeBond(p1) LB_freeBond(p1)
#define freeAsyncio(p1) LB_freeAsyncio(p1)
#define freeAsyncioRA(p1) LB_freeAsyncioRA(p1)
#define getAsyncio() LB_getAsyncio()
#define getAsyncioNoWait() LB_getAsyncioNoWait()
#define getAsyncioNoWaitRA() LB_getAsyncioNoWaitRA()
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -143,6 +143,7 @@ add_library(nwcore SHARED
library/os/alarm.c
library/os/config.c
nss/cache/control.c
nss/cache/asyncio.c
library/fsm/fsmnw.c
library/latch/intlatch.c
library/latch/latch.c

146
src/core/nss/cache/asyncio.c vendored Normal file
View File

@@ -0,0 +1,146 @@
/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) Initialization module
|
|---------------------------------------------------------------------------
|
| $Author: vandana $
| $Date: 2005-08-10 01:03:51 +0530 (Wed, 10 Aug 2005) $
|
| $RCSfile$
| $Revision: 1177 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Routines for allocating and managing structures for asynchronous
| requests.
+-------------------------------------------------------------------------*/
#include <stdlib.h>
#include <include/xError.h>
#include <include/xCache.h>
#include <internal/pssConfig.h>
/*
* Set up the system pool of async IO control structures
*/
ControlStore_s AsyncioControl;
ControlStore_s AsyncioControlRA;
void ASYNCIO_Init (DefaultAsyncio_s *asyncio)
{
static int instance = 0;
ASSERT_MPKNSS_LOCK();
FSM_INIT( &asyncio->io.fsm, asyncio->io.stack,
MAX_IO_FSM_DEPTH, MSGNot("Asyncio"), instance)
++instance;
}
STATUS ASYNCIO_Startup (void)
{
STATUS status;
ASSERT_MPKNSS_LOCK();
status = CONTROL_Startup( &AsyncioControl, Config.cache.numAsyncios,
sizeof(DefaultAsyncio_s), (voidfunc_t)ASYNCIO_Init);
if (status != zOK)
{
return status;
}
status = CONTROL_Startup( &AsyncioControlRA, Config.cache.numAsyncios,
sizeof(DefaultAsyncio_s), (voidfunc_t)ASYNCIO_Init);
return status;
}
void ASYNCIO_Shutdown (void)
{
ASSERT_MPKNSS_LOCK();
CONTROL_Shutdown( &AsyncioControlRA);
CONTROL_Shutdown( &AsyncioControl);
}
/*
* Get asyncio structure does not use the standard control routines
* because we don't want to use cache buffers for asyncio structures.
*/
Asyncio_s *LB_getAsyncio (void)
{
Asyncio_s *asyncio;
ASSERT_MPKNSS_LOCK();
asyncio = CONTROL_getNoAlloc( &AsyncioControl);
zASSERT(asyncio != NULL);
return asyncio;
}
/*
* Get asyncio structure does not use the standard control routines
* because we don't want to use cache buffers for asyncio structures.
* If no Asyncio's available do not wait for one. (Read Ahead case)
*/
Asyncio_s *LB_getAsyncioNoWait (void)
{
Asyncio_s *asyncio;
ASSERT_MPKNSS_LOCK();
asyncio = CONTROL_getNoAllocNoWait( &AsyncioControl);
return asyncio;
}
Asyncio_s *LB_getAsyncioNoWaitRA (void)
{
Asyncio_s *asyncio;
ASSERT_MPKNSS_LOCK();
asyncio = CONTROL_getNoAllocNoWait( &AsyncioControlRA);
return asyncio;
}
/****************************************************************************
* Free asyncio structure
*****************************************************************************/
void LB_freeAsyncio (Asyncio_s *asyncio)
{
ASSERT_MPKNSS_LOCK();
#if NSS_DEBUG IS_ENABLED
zASSERT(asyncio->fsm.sp[-1] == FSM_STACK_BOUNDARY);
asyncio->mycache = NULL;
#endif
CONTROL_FREE(asyncio);
}
void LB_freeAsyncioRA (Asyncio_s *asyncio)
{
ASSERT_MPKNSS_LOCK();
#if NSS_DEBUG IS_ENABLED
zASSERT(asyncio->fsm.sp[-1] == FSM_STACK_BOUNDARY);
asyncio->mycache = NULL;
#endif
CONTROL_FREE(asyncio);
}

View File

@@ -27,6 +27,7 @@ if(MARS_NWE_BUILD_NWFS_TESTS)
add_subdirectory(core/worktodo)
add_subdirectory(core/alarm)
add_subdirectory(core/control)
add_subdirectory(core/asyncio)
add_subdirectory(core/config)
add_subdirectory(core/parse)
add_subdirectory(core/fsm)

View File

@@ -13,6 +13,7 @@ add_subdirectory(schedule)
add_subdirectory(worktodo)
add_subdirectory(alarm)
add_subdirectory(control)
add_subdirectory(asyncio)
add_subdirectory(config)
add_subdirectory(parse)
add_subdirectory(fsm)

View File

@@ -0,0 +1,3 @@
add_executable(test_nwcore_asyncio test_nwcore_asyncio.c)
target_link_libraries(test_nwcore_asyncio PRIVATE mars_nwe::core)
add_test(NAME nwcore.asyncio COMMAND test_nwcore_asyncio)

View File

@@ -0,0 +1,45 @@
#include <include/xCache.h>
#include <internal/nCache.h>
#include <internal/pssConfig.h>
#include <include/pssmpk.h>
#include <stdio.h>
#define CHECK(expr) \
do { \
if (!(expr)) { \
fprintf(stderr, "CHECK failed: %s:%d: %s\n", __FILE__, __LINE__, #expr); \
return 1; \
} \
} while (0)
int main(void)
{
configStartup();
Config.cache.numAsyncios = 2;
MPKNSS_LOCK();
CHECK(ASYNCIO_Startup() == zOK);
Asyncio_s *first = LB_getAsyncioNoWait();
Asyncio_s *second = LB_getAsyncioNoWait();
CHECK(first != NULL);
CHECK(second != NULL);
CHECK(first != second);
CHECK(LB_getAsyncioNoWait() == NULL);
CHECK(first->status == zOK);
CHECK(second->status == zOK);
LB_freeAsyncio(first);
CHECK(LB_getAsyncioNoWait() == first);
LB_freeAsyncio(first);
LB_freeAsyncio(second);
Asyncio_s *ra = LB_getAsyncioNoWaitRA();
CHECK(ra != NULL);
LB_freeAsyncioRA(ra);
ASYNCIO_Shutdown();
MPKNSS_UNLOCK();
return 0;
}