Skip to content

Commit

Permalink
tracking down thread-races and sigpipe failure
Browse files Browse the repository at this point in the history
  • Loading branch information
pjstevns committed Nov 27, 2009
1 parent 814b120 commit 0a302ee
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/clientbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void ci_read_cb(clientbase_t *self)
self->bytes_rx += t; // Update our byte counter
self->client_state = CLIENT_OK;
g_string_append_len(self->read_buffer, ibuf, t);
TRACE(TRACE_DEBUG,"read [%u:%s]", t, ibuf);
TRACE(TRACE_DEBUG,"read [%u:%s]", t, t?ibuf:"(null)");
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/dm_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ void trace(trace_t level, const char * module, const char * function, int line,
trace_t syslog_level;
va_list ap, cp;

gchar *message;
gchar *message = NULL;
static int configured=0;
size_t l, maxlen=120;

/* Return now if we're not logging anything. */
if (! level & TRACE_STDERR && ! level & TRACE_SYSLOG)
if ( !(level & TRACE_STDERR) && !(level & TRACE_SYSLOG))
return;

va_start(ap, formatstring);
Expand All @@ -105,7 +105,7 @@ void trace(trace_t level, const char * module, const char * function, int line,

if (level & TRACE_STDERR) {
time_t now = time(NULL);
struct tm *tmp = localtime(&now);
struct tm tmp;
char date[32];

if (! configured) {
Expand All @@ -115,7 +115,8 @@ void trace(trace_t level, const char * module, const char * function, int line,
}

memset(date,0,sizeof(date));
strftime(date,32,"%b %d %H:%M:%S", tmp);
localtime_r(&now, &tmp);
strftime(date,32,"%b %d %H:%M:%S", &tmp);

fprintf(stderr, STDERRFORMAT, date, hostname, __progname?__progname:"", getpid(),
g_thread_self(), trace_to_text(level), module, function, line, message);
Expand Down
3 changes: 2 additions & 1 deletion src/dm_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ void create_current_timestring(timestring_t * timestring)
if (time(&td) == -1)
TRACE(TRACE_EMERG, "error getting time from OS");

tm = *localtime(&td); /* get components */
memset(&tm,0,sizeof(tm));
localtime_r(&td, &tm); /* get components */
strftime((char *) timestring, sizeof(timestring_t),
"%Y-%m-%d %H:%M:%S", &tm);
}
Expand Down
3 changes: 1 addition & 2 deletions src/imap4.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void socket_write_cb(int fd UNUSED, short what, void *arg)
{
ImapSession *session = (ImapSession *)arg;

TRACE(TRACE_DEBUG,"[%p] what [%d] state [%d] command_state [%d]", session, what, session->state, session->command_state);
// TRACE(TRACE_DEBUG,"[%p] what [%d] state [%d] command_state [%d]", session, what, session->state, session->command_state);

switch(session->state) {
case CLIENTSTATE_LOGOUT:
Expand Down Expand Up @@ -160,7 +160,6 @@ void imap_cb_read(void *arg)
void socket_read_cb(int fd UNUSED, short what, void *arg)
{
ImapSession *session = (ImapSession *)arg;
TRACE(TRACE_DEBUG,"[%p] what [%d] state [%d] command_state [%d]", session, what, session->state, session->command_state);
if (what == EV_READ)
imap_cb_read(session);
else if (what == EV_TIMEOUT && session->ci->cb_time)
Expand Down
2 changes: 1 addition & 1 deletion src/imapcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void cmd_free(cmd_t *cmd)
ImapSession *self = D->session; \
g_mutex_lock(self->mutex)

//dbmail_imap_session_buff_flush(D->session);
#define NOTIFY_DONE(D) \
dbmail_imap_session_buff_flush(D->session); \
D->session->command_state = TRUE; \
g_mutex_unlock(D->session->mutex); \
g_async_queue_push(queue, (gpointer)D); \
Expand Down

0 comments on commit 0a302ee

Please sign in to comment.