track upcoming fix for NTP-Bug 889 (avoid calling malloc()

during SIGIO handling)
This commit is contained in:
kardel 2007-08-18 13:18:23 +00:00
parent b53aba8a32
commit 9e20ecb745
1 changed files with 29 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: recvbuff.c,v 1.5 2007/06/24 16:55:12 kardel Exp $ */
/* $NetBSD: recvbuff.c,v 1.6 2007/08/18 13:18:23 kardel Exp $ */
#ifdef HAVE_CONFIG_H
# include <config.h>
@ -164,29 +164,13 @@ get_free_recv_buffer(void)
recvbuf_t * buffer = NULL;
LOCK();
buffer = ISC_LIST_HEAD(free_recv_list);
if (buffer == NULL)
if (buffer != NULL)
{
/*
* See if more are available
*/
if (create_buffers(RECV_INC) <= 0)
{
msyslog(LOG_ERR, "No more memory for recvufs");
UNLOCK();
return (NULL);
}
buffer = ISC_LIST_HEAD(free_recv_list);
if (buffer == NULL)
{
msyslog(LOG_ERR, "Failed to obtain more memory for recvbufs");
UNLOCK();
return (NULL);
}
ISC_LIST_DEQUEUE(free_recv_list, buffer, link);
free_recvbufs--;
initialise_buffer(buffer);
(buffer->used)++;
}
ISC_LIST_DEQUEUE(free_recv_list, buffer, link);
free_recvbufs--;
initialise_buffer(buffer);
(buffer->used)++;
UNLOCK();
return (buffer);
}
@ -196,6 +180,29 @@ get_full_recv_buffer(void)
{
recvbuf_t *rbuf;
LOCK();
/*
* make sure there are free buffers when we
* wander off to do lengthy paket processing with
* any buffer we grab from the full list.
*
* fixes malloc() interrupted by SIGIO risk
* (Bug 889)
*/
rbuf = ISC_LIST_HEAD(free_recv_list);
if (rbuf == NULL) {
/*
* try to get us some more buffers
*/
if (create_buffers(RECV_INC) <= 0)
{
msyslog(LOG_ERR, "No more memory for recvufs");
}
}
/*
* try to grab a full buffer
*/
rbuf = ISC_LIST_HEAD(full_recv_list);
if (rbuf != NULL)
{