mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-19 06:36:51 +08:00
SNMP: Update threadsync not to use mem_malloc - memory can be instantiated statically since it is only needed once per threadsync instance
This commit is contained in:
@@ -54,7 +54,7 @@ extern const struct snmp_mib mib2;
|
||||
#if SNMP_USE_NETCONN
|
||||
#include "lwip/apps/snmp_threadsync.h"
|
||||
void snmp_mib2_lwip_synchronizer(snmp_threadsync_called_fn fn, void* arg);
|
||||
extern struct snmp_threadsync_locks snmp_mib2_lwip_locks;
|
||||
extern struct snmp_threadsync_instance snmp_mib2_lwip_locks;
|
||||
#endif
|
||||
|
||||
#ifndef SNMP_SYSSERVICES
|
||||
|
||||
@@ -47,20 +47,40 @@ extern "C" {
|
||||
typedef void (*snmp_threadsync_called_fn)(void* arg);
|
||||
typedef void (*snmp_threadsync_synchronizer_fn)(snmp_threadsync_called_fn fn, void* arg);
|
||||
|
||||
struct snmp_threadsync_locks
|
||||
|
||||
struct threadsync_data
|
||||
{
|
||||
union {
|
||||
snmp_err_t u8;
|
||||
u16_t u16;
|
||||
} retval;
|
||||
union {
|
||||
const u32_t *root_oid;
|
||||
void *value;
|
||||
} arg1;
|
||||
union {
|
||||
u8_t root_oid_len;
|
||||
u16_t len;
|
||||
} arg2;
|
||||
const struct snmp_threadsync_node *threadsync_node;
|
||||
struct snmp_node_instance proxy_instance;
|
||||
};
|
||||
|
||||
struct snmp_threadsync_instance
|
||||
{
|
||||
sys_sem_t sem;
|
||||
sys_mutex_t sem_usage_mutex;
|
||||
snmp_threadsync_synchronizer_fn sync_fn;
|
||||
struct threadsync_data data;
|
||||
};
|
||||
|
||||
/* thread sync node */
|
||||
struct snmp_threadsync_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct snmp_leaf_node node;
|
||||
const struct snmp_leaf_node *target;
|
||||
struct snmp_threadsync_locks *locks;
|
||||
struct snmp_leaf_node node;
|
||||
const struct snmp_leaf_node *target;
|
||||
struct snmp_threadsync_instance *instance;
|
||||
};
|
||||
|
||||
snmp_err_t snmp_threadsync_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance);
|
||||
@@ -73,7 +93,7 @@ snmp_err_t snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oi
|
||||
(target), \
|
||||
(locks) }
|
||||
|
||||
void snmp_threadsync_init(struct snmp_threadsync_locks *locks, snmp_threadsync_synchronizer_fn sync_fn);
|
||||
void snmp_threadsync_init(struct snmp_threadsync_instance *instance, snmp_threadsync_synchronizer_fn sync_fn);
|
||||
|
||||
#endif /* LWIP_SNMP */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user