CIRCLEQ patch submitted by Jay Pfeifer
This commit is contained in:
@@ -186,7 +186,7 @@ struct connection {
|
|||||||
|
|
||||||
char *log_file_name; /* name of log file */
|
char *log_file_name; /* name of log file */
|
||||||
FILE *log_file; /* possibly open FILE */
|
FILE *log_file; /* possibly open FILE */
|
||||||
CIRCLEQ_ENTRY(connection) log_link; /* linked list of open conns */
|
TAILQ_ENTRY(connection) log_link; /* linked list of open conns */
|
||||||
bool log_file_err; /* only bitch once */
|
bool log_file_err; /* only bitch once */
|
||||||
|
|
||||||
struct spd_route spd;
|
struct spd_route spd;
|
||||||
|
|||||||
+15
-15
@@ -65,7 +65,7 @@ const char *base_perpeer_logdir = PERPEERLOGDIR;
|
|||||||
static int perpeer_count = 0;
|
static int perpeer_count = 0;
|
||||||
|
|
||||||
/* from sys/queue.h */
|
/* from sys/queue.h */
|
||||||
static CIRCLEQ_HEAD(,connection) perpeer_list;
|
static TAILQ_HEAD(perpeer, connection) perpeer_list;
|
||||||
|
|
||||||
|
|
||||||
/* Context for logging.
|
/* Context for logging.
|
||||||
@@ -88,19 +88,19 @@ init_log(const char *program)
|
|||||||
if (log_to_syslog)
|
if (log_to_syslog)
|
||||||
openlog(program, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
|
openlog(program, LOG_CONS | LOG_NDELAY | LOG_PID, LOG_AUTHPRIV);
|
||||||
|
|
||||||
CIRCLEQ_INIT(&perpeer_list);
|
TAILQ_INIT(&perpeer_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
close_peerlog(void)
|
close_peerlog(void)
|
||||||
{
|
{
|
||||||
/* end of circular queue is given by pointer to "HEAD"
|
/* exit if the queue has not been initialized */
|
||||||
* BUT if the queue is not initialized, this won't be true
|
if (TAILQ_LAST(&perpeer_list, perpeer) == NULL)
|
||||||
* so we must guard by test perpeer_list.cqh_first != NULL
|
return;
|
||||||
*/
|
|
||||||
if (perpeer_list.cqh_first != NULL)
|
/* end of queue is given by pointer to "HEAD" */
|
||||||
while (perpeer_list.cqh_first != (void *)&perpeer_list)
|
while (TAILQ_LAST(&perpeer_list, perpeer) != (void *)&perpeer_list)
|
||||||
perpeer_logclose(perpeer_list.cqh_first);
|
perpeer_logclose(TAILQ_LAST(&perpeer_list, perpeer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -231,7 +231,7 @@ perpeer_logclose(struct connection *c)
|
|||||||
{
|
{
|
||||||
passert(perpeer_count > 0);
|
passert(perpeer_count > 0);
|
||||||
|
|
||||||
CIRCLEQ_REMOVE(&perpeer_list, c, log_link);
|
TAILQ_REMOVE(&perpeer_list, c, log_link);
|
||||||
perpeer_count--;
|
perpeer_count--;
|
||||||
fclose(c->log_file);
|
fclose(c->log_file);
|
||||||
c->log_file=NULL;
|
c->log_file=NULL;
|
||||||
@@ -366,13 +366,13 @@ open_peerlog(struct connection *c)
|
|||||||
while (perpeer_count >= MAX_PEERLOG_COUNT)
|
while (perpeer_count >= MAX_PEERLOG_COUNT)
|
||||||
{
|
{
|
||||||
/* can not be NULL because perpeer_count > 0 */
|
/* can not be NULL because perpeer_count > 0 */
|
||||||
passert(perpeer_list.cqh_last != (void *)&perpeer_list);
|
passert(TAILQ_LAST(&perpeer_list, perpeer) != (void *)&perpeer_list);
|
||||||
|
|
||||||
perpeer_logclose(perpeer_list.cqh_last);
|
perpeer_logclose(TAILQ_LAST(&perpeer_list, perpeer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* insert this into the list */
|
/* insert this into the list */
|
||||||
CIRCLEQ_INSERT_HEAD(&perpeer_list, c, log_link);
|
TAILQ_INSERT_HEAD(&perpeer_list, c, log_link);
|
||||||
passert(c->log_file != NULL);
|
passert(c->log_file != NULL);
|
||||||
perpeer_count++;
|
perpeer_count++;
|
||||||
}
|
}
|
||||||
@@ -406,8 +406,8 @@ peerlog(const char *prefix, const char *m)
|
|||||||
fprintf(cur_connection->log_file, "%s %s%s\n", datebuf, prefix, m);
|
fprintf(cur_connection->log_file, "%s %s%s\n", datebuf, prefix, m);
|
||||||
|
|
||||||
/* now move it to the front of the list */
|
/* now move it to the front of the list */
|
||||||
CIRCLEQ_REMOVE(&perpeer_list, cur_connection, log_link);
|
TAILQ_REMOVE(&perpeer_list, cur_connection, log_link);
|
||||||
CIRCLEQ_INSERT_HEAD(&perpeer_list, cur_connection, log_link);
|
TAILQ_INSERT_HEAD(&perpeer_list, cur_connection, log_link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user