projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
548543e
)
write_riemann: do not deadlock when sending from flush
author
Pierre-Yves Ritschard
<pyr@spootnik.org>
Thu, 14 Apr 2016 08:12:27 +0000
(10:12 +0200)
committer
Pierre-Yves Ritschard
<pyr@spootnik.org>
Thu, 14 Apr 2016 08:15:31 +0000
(10:15 +0200)
src/write_riemann.c
patch
|
blob
|
history
diff --git
a/src/write_riemann.c
b/src/write_riemann.c
index
1836b6b
..
f836b9d
100644
(file)
--- a/
src/write_riemann.c
+++ b/
src/write_riemann.c
@@
-136,21
+136,18
@@
static int wrr_disconnect(struct riemann_host *host) /* {{{ */
*
* Acquires the host lock, disconnects on errors.
*/
*
* Acquires the host lock, disconnects on errors.
*/
-static int wrr_send(struct riemann_host *host, riemann_message_t *msg) /* {{{ */
+static int wrr_send
_nolock
(struct riemann_host *host, riemann_message_t *msg) /* {{{ */
{
int status = 0;
{
int status = 0;
- pthread_mutex_lock (&host->lock);
status = wrr_connect(host);
if (status != 0) {
status = wrr_connect(host);
if (status != 0) {
- pthread_mutex_unlock(&host->lock);
return status;
}
status = riemann_client_send_message(host->client, msg);
if (status != 0) {
wrr_disconnect(host);
return status;
}
status = riemann_client_send_message(host->client, msg);
if (status != 0) {
wrr_disconnect(host);
- pthread_mutex_unlock(&host->lock);
return status;
}
return status;
}
@@
-166,16
+163,24
@@
static int wrr_send(struct riemann_host *host, riemann_message_t *msg) /* {{{ */
if (response == NULL)
{
wrr_disconnect(host);
if (response == NULL)
{
wrr_disconnect(host);
- pthread_mutex_unlock(&host->lock);
return errno;
}
riemann_message_free(response);
}
return errno;
}
riemann_message_free(response);
}
- pthread_mutex_unlock (&host->lock);
return 0;
} /* }}} int wrr_send */
return 0;
} /* }}} int wrr_send */
+static int wrr_send(struct riemann_host *host, riemann_message_t *msg)
+{
+ int status = 0;
+
+ pthread_mutex_lock (&host->lock);
+ status = wrr_send_nolock(host, msg);
+ pthread_mutex_unlock (&host->lock);
+ return status;
+}
+
static riemann_message_t *wrr_notification_to_message(struct riemann_host *host, /* {{{ */
notification_t const *n)
{
static riemann_message_t *wrr_notification_to_message(struct riemann_host *host, /* {{{ */
notification_t const *n)
{
@@
-461,7
+466,7
@@
static int wrr_batch_flush_nolock(cdtime_t timeout,
if ((host->batch_init + timeout) > now)
return status;
}
if ((host->batch_init + timeout) > now)
return status;
}
- wrr_send(host, host->batch_msg);
+ wrr_send
_nolock
(host, host->batch_msg);
riemann_message_free(host->batch_msg);
if (host->client_type != RIEMANN_CLIENT_UDP)
riemann_message_free(host->batch_msg);
if (host->client_type != RIEMANN_CLIENT_UDP)