if (p->socket.tcptls_session)
ast_mutex_lock(&p->socket.tcptls_session->lock);
- if (p->socket.type & SIP_TRANSPORT_UDP)
+ if (p->socket.type & SIP_TRANSPORT_UDP) {
res = sendto(p->socket.fd, data->str, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in));
- else {
- if (p->socket.tcptls_session->f)
+ } else if (p->socket.tcptls_session) {
+ if (p->socket.tcptls_session->f) {
res = ast_tcptls_server_write(p->socket.tcptls_session, data->str, len);
- else
+ } else {
ast_debug(2, "No p->socket.tcptls_session->f len=%d\n", len);
- }
+ }
+ } else {
+ ast_debug(2, "Socket type is TCP but no tcptls_session is present to write to\n");
+ return XMIT_ERROR;
+ }
if (p->socket.tcptls_session)
ast_mutex_unlock(&p->socket.tcptls_session->lock);
else
ast_log(LOG_NOTICE, "'%s' is not a valid transport type. if no other is specified, udp will be used.\n", trans);
- if (!peer->socket.type) /*!< The first transport listed should be used for outgoing */
+ if (!peer->socket.type) { /*!< The first transport listed should be used for outgoing */
peer->socket.type = peer->transports;
+ peer->socket.fd = -1;
+ }
}
} else if (realtime && !strcasecmp(v->name, "regseconds")) {
ast_get_time_t(v->value, ®seconds, 0, NULL);