projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'github/pr/1927'
[collectd.git]
/
src
/
apache.c
diff --git
a/src/apache.c
b/src/apache.c
index
baa6081
..
c02dfe0
100644
(file)
--- a/
src/apache.c
+++ b/
src/apache.c
@@
-25,9
+25,9
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include "configfile.h"
#include <curl/curl.h>
#include <curl/curl.h>
@@
-63,8
+63,10
@@
typedef struct apache_s apache_t;
/* TODO: Remove this prototype */
static int apache_read_host (user_data_t *user_data);
/* TODO: Remove this prototype */
static int apache_read_host (user_data_t *user_data);
-static void apache_free (
apache_t *st
)
+static void apache_free (
void *arg
)
{
{
+ apache_t *st = arg;
+
if (st == NULL)
return;
if (st == NULL)
return;
@@
-98,14
+100,14
@@
static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb,
return (0);
}
return (0);
}
- if (len
<
= 0)
+ if (len
=
= 0)
return (len);
if ((st->apache_buffer_fill + len) >= st->apache_buffer_size)
{
char *temp;
return (len);
if ((st->apache_buffer_fill + len) >= st->apache_buffer_size)
{
char *temp;
- temp =
(char *)
realloc (st->apache_buffer,
+ temp = realloc (st->apache_buffer,
st->apache_buffer_fill + len + 1);
if (temp == NULL)
{
st->apache_buffer_fill + len + 1);
if (temp == NULL)
{
@@
-137,7
+139,7
@@
static size_t apache_header_callback (void *buf, size_t size, size_t nmemb,
return (0);
}
return (0);
}
- if (len
<
= 0)
+ if (len
=
= 0)
return (len);
/* look for the Server header */
return (len);
/* look for the Server header */
@@
-172,7
+174,6
@@
static size_t apache_header_callback (void *buf, size_t size, size_t nmemb,
static int config_add (oconfig_item_t *ci)
{
apache_t *st;
static int config_add (oconfig_item_t *ci)
{
apache_t *st;
- int i;
int status;
st = calloc (1, sizeof (*st));
int status;
st = calloc (1, sizeof (*st));
@@
-192,7
+193,7
@@
static int config_add (oconfig_item_t *ci)
}
assert (st->name != NULL);
}
assert (st->name != NULL);
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-238,14
+239,8
@@
static int config_add (oconfig_item_t *ci)
if (status == 0)
{
if (status == 0)
{
- user_data_t ud;
char callback_name[3*DATA_MAX_NAME_LEN];
char callback_name[3*DATA_MAX_NAME_LEN];
- memset (&ud, 0, sizeof (ud));
- ud.data = st;
- ud.free_func = (void *) apache_free;
-
- memset (callback_name, 0, sizeof (callback_name));
ssnprintf (callback_name, sizeof (callback_name),
"apache/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
ssnprintf (callback_name, sizeof (callback_name),
"apache/%s/%s",
(st->host != NULL) ? st->host : hostname_g,
@@
-255,7
+250,11
@@
static int config_add (oconfig_item_t *ci)
/* name = */ callback_name,
/* callback = */ apache_read_host,
/* interval = */ 0,
/* name = */ callback_name,
/* callback = */ apache_read_host,
/* interval = */ 0,
- /* user_data = */ &ud);
+ &(user_data_t) {
+ .data = st,
+ .free_func = apache_free,
+ });
+
}
if (status != 0)
}
if (status != 0)
@@
-270,9
+269,8
@@
static int config_add (oconfig_item_t *ci)
static int config (oconfig_item_t *ci)
{
int status = 0;
static int config (oconfig_item_t *ci)
{
int status = 0;
- int i;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-463,8
+461,7
@@
static void submit_scoreboard (char *buf, apache_t *st)
long long response_start = 0LL;
long long response_end = 0LL;
long long response_start = 0LL;
long long response_end = 0LL;
- int i;
- for (i = 0; buf[i] != '\0'; i++)
+ for (int i = 0; buf[i] != '\0'; i++)
{
if (buf[i] == '.') open++;
else if (buf[i] == '_') waiting++;
{
if (buf[i] == '.') open++;
else if (buf[i] == '_') waiting++;