write_event(event_channel, use_jsock, event);
if (strchr(event_channel, '.')) {
char *main_channel = strdup(event_channel);
- char *p = strchr(main_channel, '.');
+ char *p;
+ switch_assert(main_channel);
+ p = strchr(main_channel, '.');
if (p) *p = '\0';
write_event(main_channel, use_jsock, event);
free(main_channel);
if (strchr(method, '.')) {
char *p;
main_method = strdup(method);
+ switch_assert(main_method);
if ((p = strchr(main_method, '.'))) {
*p = '\0';
}
if (!zstr(str)) {
edup = strdup(str);
+ switch_assert(edup);
cur = edup;
if (strchr(edup, ' ')) {
if (arg) {
switch_safe_free(dup_arg);
dup_arg = strdup(arg);
+ switch_assert(dup_arg);
check_cmd = dup_arg;
if ((next = strchr(check_cmd, ' '))) {
*next++ = '\0';
if (!zstr(to)) {
if (strchr(to, '+')) {
pproto = strdup(to);
+ switch_assert(pproto);
if ((to = strchr(pproto, '+'))) {
*to++ = '\0';
}
if (strchr(event_channel, '.')) {
char *p;
main_event_channel = strdup(event_channel);
+ switch_assert(main_event_channel);
if ((p = strchr(main_event_channel, '.'))) {
*p = '\0';
}
}
-static int runtime(verto_profile_t *profile)
+static void runtime(verto_profile_t *profile)
{
int i;
- int r = 0;
int listeners = 0;
for (i = 0; i < profile->i; i++) {
ok++;
}
- if (ok && mcast_socket_create(profile->mcast_ip, profile->mcast_port + 1, &profile->mcast_pub, MCAST_SEND | MCAST_TTL_HOST) > 0) {
+ if (mcast_socket_create(profile->mcast_ip, profile->mcast_port + 1, &profile->mcast_pub, MCAST_SEND | MCAST_TTL_HOST) > 0) {
mcast_socket_close(&profile->mcast_sub);
ok = 0;
}
mcast_socket_close(&profile->mcast_pub);
}
- if (r) {
- kill_profile(profile);
- }
-
- return r;
-
}
static void do_shutdown(void)
strncpy(host, p, end - p);
if (*(end+1) == ':' && end + 2 < end_of_p(input)) {
end += 2;
- if (end) {
+ if (*end) {
*port = (uint16_t)atoi(end);
}
}
for (param = switch_xml_child(xprofile, "param"); param; param = param->next) {
char *var = NULL;
char *val = NULL;
- int i = 0;
var = (char *) switch_xml_attr_soft(param, "name");
val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "bind-local")) {
const char *secure = switch_xml_attr_soft(param, "secure");
- if (i < MAX_BIND) {
+ if (profile->i < MAX_BIND) {
parse_ip(profile->ip[profile->i].local_ip, sizeof(profile->ip[profile->i].local_ip), &profile->ip[profile->i].local_port, val);
if (switch_true(secure)) {
profile->ip[profile->i].secure = 1;
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "verto_orig_dest", dest);
if (zstr(switch_event_get_header(var_event, "origination_callee_id_number"))) {
+ char *p;
char *trimmed_dest = strdup(dest);
- char *p = strchr(trimmed_dest, '@');
+ switch_assert(trimmed_dest);
+ p = strchr(trimmed_dest, '@');
if (p) *p = '\0';
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_callee_id_number", trimmed_dest);
free(trimmed_dest);
cJSON_AddItemToObject(msg, "body", cJSON_CreateString(body));
for (eh = message_event->headers; eh; eh = eh->next) {
- if ((!strncasecmp(eh->name, "from_", 5) || !strncasecmp(eh->name, "to_", 3))) {
+ if (!strncasecmp(eh->name, "from_", 5) || !strncasecmp(eh->name, "to_", 3)) {
cJSON_AddItemToObject(msg, eh->name, cJSON_CreateString(eh->value));
}
}
}
wsh->uri = malloc((e-p) + 1);
+
+ if (!wsh->uri) goto err;
+
strncpy(wsh->uri, p, e-p);
*(wsh->uri + (e-p)) = '\0';
int ms = 1;
if (wsh->block) {
- if (sanity < WS_WRITE_SANITY * 3 / 4) {
- ms = 50;
- } else if (sanity < WS_WRITE_SANITY / 2) {
+ if (sanity < WS_WRITE_SANITY / 2) {
ms = 25;
+ } else if (sanity < WS_WRITE_SANITY * 3 / 4) {
+ ms = 50;
}
}
ms_sleep(ms);
int ms = 1;
if (wsh->block) {
- if (sanity < WS_WRITE_SANITY * 3 / 4) {
- ms = 50;
- } else if (sanity < WS_WRITE_SANITY / 2) {
+ if (sanity < WS_WRITE_SANITY / 2) {
ms = 25;
+ } else if (sanity < WS_WRITE_SANITY * 3 / 4) {
+ ms = 50;
}
}
ms_sleep(ms);
if (code < 0) {
int ssl_err = SSL_get_error(wsh->ssl, code);
- if (code < 0 && !SSL_WANT_READ_WRITE(ssl_err)) {
+ if (!SSL_WANT_READ_WRITE(ssl_err)) {
return -1;
}
}
if (wsh->datalen < need) {
ssize_t bytes = ws_raw_read(wsh, wsh->buffer + wsh->datalen, 9 - wsh->datalen, WS_BLOCK);
- if (bytes < 0 || (wsh->datalen += bytes) < need) {
+ if (bytes < 0 || (wsh->datalen + bytes) < need) {
/* too small - protocol err */
return ws_close(wsh, WS_NONE);
}