Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Oct 4, 2024
1 parent 04adb32 commit 637cab6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
34 changes: 28 additions & 6 deletions modules/rtp.io/rtp_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ struct rtp_io_desc *rpi_descp;
rtp_io_env_append(&rpi_descp->env, _e); \
}

int
rio_init(void)
{
int nsocks;
size_t asize;

nsocks = count_child_processes();

if (nsocks <= 1)
goto e0;

LM_DBG("allocating %s(%d)\n", exports.name, nsocks);

asize = sizeof(struct rtp_io_desc) + (nsocks * sizeof(int) * 2);
rpi_descp = malloc(asize);
if (rpi_descp == NULL)
goto e0;

memset(rpi_descp, '\0', asize);
return 0;
e0:
return -1;
}

static int mod_init(void)
{
int nsocks;
Expand All @@ -138,12 +162,10 @@ static int mod_init(void)

LM_DBG("initializing %s(%d)\n", exports.name, nsocks);

asize = sizeof(struct rtp_io_desc) + (nsocks * sizeof(int) * 2);
rpi_descp = malloc(asize);
if (rpi_descp == NULL)
goto e0;

memset(rpi_descp, '\0', asize);
if (rpi_descp == NULL) {
if (rio_init() != 0)
goto e0;
}

for (int i = 0; i < howmany(argv_stat, *argv_stat); i++) {
ENV_ADD(argv_stat[i], e1);
Expand Down
2 changes: 2 additions & 0 deletions modules/rtp.io/rtp_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ struct rtp_io_desc {
};

extern struct rtp_io_desc *rpi_descp;

int rio_init(void);
6 changes: 6 additions & 0 deletions modules/rtp.io/rtp_io_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <string.h>

#include "../../sr_module.h"
#include "../../pt.h"

#include "rtp_io.h"
#include "rtp_io_util.h"
Expand All @@ -14,9 +15,14 @@ rio_set_rtpp_args(modparam_t type, void *val)

p = (char *)val;


if (p == NULL || *p == '\0') {
return 0;
}
if (rpi_descp == NULL) {
if (rio_init() != 0)
return -1;
}
do {
char *ep = strchr(p, ' ');
if (ep != NULL) {
Expand Down

0 comments on commit 637cab6

Please sign in to comment.