Skip to content

Commit b70f6a1

Browse files
committed
Extend after_success API to take two pointers - one for static
structs and one for a dynamic. Use dynamic for the TTL subcommand and static for the module-specific command.
1 parent 722bbe7 commit b70f6a1

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

src/commands/rpcpv1_ul.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ rtpp_command_ul_opts_free(struct ul_opts *ulop)
172172
FREE_IF_NULL(ulop->codecs);
173173
FREE_IF_NULL(ulop->ia[0]);
174174
FREE_IF_NULL(ulop->ia[1]);
175+
for (int i = 0; i < MAX_SUBC_NUM; i++)
176+
FREE_IF_NULL(ulop->after_success[i].args.dyn);
175177
free(ulop);
176178
}
177179

@@ -689,7 +691,7 @@ rtpp_command_ul_handle(const struct rtpp_cfg *cfsp, struct rtpp_command *cmd, in
689691
.resp = &(ulop->reply.subc_res[i])
690692
};
691693
rsc.resp->result = ulop->after_success[i].handler(
692-
ulop->after_success[i].arg, &rsc);
694+
&ulop->after_success[i].args, &rsc);
693695
}
694696
ul_reply_port(cmd, &ulop->reply);
695697
rtpp_command_ul_opts_free(ulop);

src/commands/rpcpv1_ul.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,26 @@
2828
#ifndef _RTPP_COMMAND_UL_H_
2929
#define _RTPP_COMMAND_UL_H_
3030

31+
struct rtpp_cfg;
3132
struct ul_opts;
3233
struct ul_reply;
3334
struct rtpp_command;
3435
struct rtpp_session;
3536
struct rtpp_subc_ctx;
37+
struct after_success_h_args;
3638

37-
DEFINE_RAW_METHOD(after_success, int, void *, const struct rtpp_subc_ctx *);
39+
DEFINE_RAW_METHOD(after_success, int, const struct after_success_h_args *,
40+
const struct rtpp_subc_ctx *);
41+
42+
struct after_success_h_args {
43+
void *stat;
44+
void *dyn;
45+
46+
};
3847

3948
struct after_success_h {
4049
after_success_t handler;
41-
void *arg;
50+
struct after_success_h_args args;
4251
};
4352

4453
struct ul_opts *rtpp_command_ul_opts_parse(const struct rtpp_cfg *,

src/rtpp_modman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ rtpp_modman_get_ul_subc_h(struct rtpp_modman *self, unsigned int mod_id,
164164
if (tmp->has.ul_subc_h == 0)
165165
break;
166166
ashp->handler = (after_success_t)tmp->ul_subc_handle;
167-
ashp->arg = tmp;
167+
ashp->args.stat = tmp;
168168
return (0);
169169
}
170170
return (-1);

src/rtpp_module_if.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#include "rtpp_wi_sgnl.h"
7575
#include "rtpp_weakref.h"
7676
#include "rtpp_command_sub.h"
77+
#include "commands/rpcpv1_ul.h"
7778
#ifdef RTPP_CHECK_LEAKS
7879
#include "rtpp_memdeb_internal.h"
7980
#endif
@@ -100,7 +101,7 @@ static int rtpp_mif_start(struct rtpp_module_if *, const struct rtpp_cfg *);
100101
static void rtpp_mif_do_acct(struct rtpp_module_if *, struct rtpp_acct *);
101102
static void rtpp_mif_do_acct_rtcp(struct rtpp_module_if *, struct rtpp_acct_rtcp *);
102103
static int rtpp_mif_get_mconf(struct rtpp_module_if *, struct rtpp_module_conf **);
103-
static int rtpp_mif_ul_subc_handle(struct rtpp_module_if *,
104+
static int rtpp_mif_ul_subc_handle(const struct after_success_h_args *,
104105
const struct rtpp_subc_ctx *);
105106
static int rtpp_mif_construct(struct rtpp_module_if *self, const struct rtpp_cfg *);
106107
static void rtpp_mif_kaput(struct rtpp_module_if *self);
@@ -512,11 +513,13 @@ rtpp_mif_get_mconf(struct rtpp_module_if *self, struct rtpp_module_conf **mcpp)
512513
}
513514

514515
static int
515-
rtpp_mif_ul_subc_handle(struct rtpp_module_if *self,
516+
rtpp_mif_ul_subc_handle(const struct after_success_h_args *ashap,
516517
const struct rtpp_subc_ctx *ctxp)
517518
{
518519
struct rtpp_module_if_priv *pvt;
520+
struct rtpp_module_if *self;
519521

522+
self = ashap->stat;
520523
PUB2PVT(self, pvt);
521524
return (pvt->mip->capi->ul_subc_handle(pvt->mpvt, ctxp));
522525
}

src/rtpp_module_if.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct rtpp_cfg;
3434
struct rtpp_module_conf;
3535
struct rtpp_mdescr;
3636
struct rtpp_subc_ctx;
37+
struct after_success_h_args;
3738

3839
DEFINE_METHOD(rtpp_module_if, rtpp_module_if_load, int, const struct rtpp_cfg *,
3940
struct rtpp_log *);
@@ -46,7 +47,7 @@ DEFINE_METHOD(rtpp_module_if, rtpp_module_if_do_acct_rtcp, void,
4647
struct rtpp_acct_rtcp *);
4748
DEFINE_METHOD(rtpp_module_if, rtpp_module_if_get_mconf, int,
4849
struct rtpp_module_conf **);
49-
DEFINE_METHOD(rtpp_module_if, rtpp_module_if_ul_subc_handle, int,
50+
DEFINE_RAW_METHOD(rtpp_module_if_ul_subc_handle, int, const struct after_success_h_args *,
5051
const struct rtpp_subc_ctx *);
5152
DEFINE_METHOD(rtpp_module_if, rtpp_module_if_kaput, void);
5253

0 commit comments

Comments
 (0)