MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / _dm_send_message

Function _dm_send_message

modules/aaa_diameter/dm_impl.c:2076–2122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2074}
2075
2076int _dm_send_message(aaa_conn *_, aaa_message *msg, struct dm_cond **reply_cond)
2077{
2078 struct timespec wait_until;
2079 struct timeval now, wait_time, res;
2080 int rc, await_reply = 0;
2081
2082 if (!msg || !my_reply_cond)
2083 return -1;
2084
2085 if (msg->type == AAA_AUTH || msg->type == AAA_CUSTOM_REQ)
2086 await_reply = 1;
2087
2088 LM_DBG("queue message for sending, type %d\n", msg->type);
2089
2090 pthread_mutex_lock(&my_reply_cond->sync.cond.mutex);
2091 dm_push_queue(msg, my_reply_cond);
2092 /* WARNING: @msg *cannot* be read anymore here! (dangling pointer) */
2093
2094 if (!await_reply) {
2095 pthread_mutex_unlock(&my_reply_cond->sync.cond.mutex);
2096 return 0;
2097 }
2098
2099 gettimeofday(&now, NULL);
2100 wait_time.tv_sec = dm_answer_timeout / 1000;
2101 wait_time.tv_usec = dm_answer_timeout % 1000 * 1000UL;
2102 LM_DBG("awaiting reply (%ld s, %ld us)...\n", wait_time.tv_sec, wait_time.tv_usec);
2103
2104 timeradd(&now, &wait_time, &res);
2105
2106 wait_until.tv_sec = res.tv_sec;
2107 wait_until.tv_nsec = res.tv_usec * 1000UL;
2108
2109 rc = pthread_cond_timedwait(&my_reply_cond->sync.cond.cond,
2110 &my_reply_cond->sync.cond.mutex, &wait_until);
2111 pthread_mutex_unlock(&my_reply_cond->sync.cond.mutex);
2112 if (rc != 0) {
2113 LM_ERR("timeout (errno: %d '%s') while awaiting Diameter "
2114 "reply\n", rc, strerror(rc));
2115 return -2;
2116 }
2117
2118 if (reply_cond)
2119 *reply_cond = my_reply_cond;
2120
2121 return 0;
2122}
2123
2124int dm_send_message(aaa_conn *_, aaa_message *req, aaa_message **reply)
2125{

Callers 4

dm_send_messageFunction · 0.85
dm_api_send_reqFunction · 0.85
dm_send_requestFunction · 0.85
dm_send_answerFunction · 0.85

Calls 1

dm_push_queueFunction · 0.85

Tested by

no test coverage detected