Newer
Older
* reallocate the buffer and return a message telling to retry.
*/
if (need > (*buf)->len && (max_len == 0 || (*buf)->len < max_len) ) {
if (max_len && max_len < need) /* truncate as needed */
/* We can only realloc malloc'ed space. */
if ((*buf)->type != DS_MALLOC)
return AST_DYNSTR_BUILD_FAILED;
*buf = ast_realloc(*buf, need + sizeof(struct ast_dynamic_str));
if (*buf == NULL) /* XXX watch out, we leak memory here */
return AST_DYNSTR_BUILD_FAILED;
(*buf)->str[offset] = '\0'; /* Truncate the partial write. */
Russell Bryant
committed
if (ts)
pthread_setspecific(ts->key, *buf);
/* va_end() and va_start() must be done before calling
* vsnprintf() again. */
return AST_DYNSTR_BUILD_RETRY;
}
/* update space used, keep in mind the truncation */
(*buf)->used = (res + offset > (*buf)->len) ? (*buf)->len : res + offset;
void ast_enable_packet_fragmentation(int sock)
{
#if defined(HAVE_IP_MTU_DISCOVER)
int val = IP_PMTUDISC_DONT;
if (setsockopt(sock, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val)))
ast_log(LOG_WARNING, "Unable to disable PMTU discovery. Large UDP packets may fail to be delivered when sent from this socket.\n");
#endif /* HAVE_IP_MTU_DISCOVER */