Commit 3d033b2e authored by Geoff Simmons's avatar Geoff Simmons

varnishevent: - bugfixes: deadlocking and incomplete formatter

parent 945cf01a
......@@ -470,10 +470,8 @@ format_incomplete(logline_t *ll, char *name, enum VSL_tag_e tag,
char *colon = strchr(name, ':');
AN(colon);
if (ll->incomplete) {
*colon = '\0';
strcpy(scratch, name);
}
if (ll->incomplete)
strncpy(scratch, name, colon - name);
else
strcpy(scratch, colon + 1);
......
......@@ -144,6 +144,12 @@ static int waiting = 0;
static char cli_config_filename[BUFSIZ] = "";
#define SIGNAL_SPSCQ_READY() do { \
AZ(pthread_mutex_lock(&spscq_ready_lock)); \
AZ(pthread_cond_signal(&spscq_ready_cond)); \
AZ(pthread_mutex_unlock(&spscq_ready_lock)); \
} while (0)
int
RDR_Waiting(void)
{
......@@ -171,11 +177,11 @@ static inline logline_t
if (VSTAILQ_EMPTY(&reader_freelist)) {
LOG_Log0(LOG_DEBUG, "Reader: waiting for free space");
AZ(pthread_mutex_lock(&data_ready_lock));
if (WRT_Waiting())
SIGNAL_SPSCQ_READY();
waiting = 1;
AZ(pthread_mutex_lock(&data_ready_lock));
waits++;
if (WRT_Waiting())
AZ(pthread_cond_signal(&spscq_ready_cond));
AZ(pthread_cond_wait(&data_ready_cond, &data_ready_lock));
rdr_free = DATA_Take_Freelist(&reader_freelist);
waiting = 0;
......@@ -210,9 +216,8 @@ submit(fd_t *entry)
return;
}
SPSCQ_Enq((void *) lp);
/* XXX: wait for a goal queue length, as in trackrdrd? */
if (WRT_Waiting())
AZ(pthread_cond_signal(&spscq_ready_cond));
SIGNAL_SPSCQ_READY();
MON_StatsUpdate(STATS_DONE);
submitted++;
}
......
......@@ -118,8 +118,11 @@ wrt_return_freelist(void)
{
DATA_Return_Freelist(&wrt_freelist, wrt_nfree);
wrt_nfree = 0;
if (RDR_Waiting())
if (RDR_Waiting()) {
AZ(pthread_mutex_lock(&data_ready_lock));
AZ(pthread_cond_signal(&data_ready_cond));
AZ(pthread_mutex_unlock(&data_ready_lock));
}
}
static inline void
......@@ -200,20 +203,18 @@ static void
/*
* wait until data are available, or quit is signaled.
* XXX: no backoff condition
* flush ouput and return space before sleeping
*/
if (wrt_nfree > 0)
wrt_return_freelist();
if (fflush(fo) != 0) {
LOG_Log(LOG_ALERT, "Output flush failed, error %d (%s)",
errno, strerror(errno));
errors++;
}
if (wrt_nfree > 0)
wrt_return_freelist();
AZ(pthread_mutex_lock(&spscq_ready_lock));
wrt->state = WRT_WAITING;
AZ(pthread_mutex_lock(&spscq_ready_lock));
/*
* run is guaranteed to be fresh after the lock
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment