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:
Dirk Ziegelmeier
2016-02-02 22:31:59 +01:00
parent 8f6cfa8769
commit 28549e35fe
4 changed files with 61 additions and 70 deletions

View File

@@ -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

View File

@@ -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 */