Code

Add rd_kafka_last_error.patch
[pkg-collectd.git] / debian / patches / rd_kafka_last_error.patch
1 Description: 'rd_kafka_errno2err' is deprecated, fix failed builds
2  Since librdkafka-0.11.0 applications should use
3  rd_kafka_last_error() to retrieve the error code from the legacy APIs.
4 Author: Pavel Rochnyack <pavel2000@ngs.ru>
5 Forwarded: https://github.com/collectd/collectd/pull/2683
7 diff --git a/src/write_kafka.c b/src/write_kafka.c
8 index 306d92ccb..17a83e0e9 100644
9 --- a/src/write_kafka.c
10 +++ b/src/write_kafka.c
11 @@ -77,6 +77,14 @@ static void kafka_log(const rd_kafka_t *rkt, int level, const char *fac,
12  }
13  #endif
14  
15 +static rd_kafka_resp_err_t kafka_error() {
16 +#if RD_KAFKA_VERSION >= 0x000b00ff
17 +  return rd_kafka_last_error();
18 +#else
19 +  return rd_kafka_errno2err(errno);
20 +#endif
21 +}
22 +
23  static uint32_t kafka_hash(const char *keydata, size_t keylen) {
24    uint32_t hash = 5381;
25    for (; keylen > 0; keylen--)
26 @@ -147,7 +155,7 @@ static int kafka_handle(struct kafka_topic_context *ctx) /* {{{ */
27      if ((ctx->topic = rd_kafka_topic_new(ctx->kafka, ctx->topic_name,
28                                           topic_conf)) == NULL) {
29        ERROR("write_kafka plugin: cannot create topic : %s\n",
30 -            rd_kafka_err2str(rd_kafka_errno2err(errno)));
31 +            rd_kafka_err2str(kafka_error()));
32        return errno;
33      }
34