X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Frrd_daemon.c;h=2b8ac5814cc3d0c2028548d22886e07f9dbe299c;hb=308bcc42e1dfbdb9bb75e4766dcdf3ff684a1f42;hp=3226c38769edbf90fd710608764b61a323df1e6a;hpb=890c744b7c09bc9959f1588ec9eaa838f8225169;p=rrdtool.git diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 3226c38..2b8ac58 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -429,7 +429,7 @@ static int add_to_wbuf(listen_socket_t *sock, char *str, size_t len) /* {{{ */ assert(sock != NULL); - new_buf = realloc(sock->wbuf, sock->wbuf_len + len + 1); + new_buf = rrd_realloc(sock->wbuf, sock->wbuf_len + len + 1); if (new_buf == NULL) { RRDD_LOG(LOG_ERR, "add_to_wbuf: realloc failed"); @@ -703,7 +703,7 @@ static gboolean tree_callback_flush (gpointer key, gpointer value, /* {{{ */ { char **temp; - temp = (char **) realloc (cfd->keys, + temp = (char **) rrd_realloc (cfd->keys, sizeof (char *) * (cfd->keys_num + 1)); if (temp == NULL) { @@ -1079,6 +1079,7 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ "UPDATE [ ...]\n" "BATCH\n" "STATS\n" + "QUIT\n" }; char *help_flush[2] = @@ -1167,6 +1168,13 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ "For more information, consult the rrdcached(1) documentation.\n" }; + char *help_quit[2] = + { + "Help for QUIT\n" + , + "Disconnect from rrdcached.\n" + }; + status = buffer_get_field (&buffer, &buffer_size, &command); if (status != 0) help_text = help_help; @@ -1186,6 +1194,8 @@ static int handle_request_help (listen_socket_t *sock, /* {{{ */ help_text = help_stats; else if (strcasecmp (command, "batch") == 0) help_text = help_batch; + else if (strcasecmp (command, "quit") == 0) + help_text = help_quit; else help_text = help_help; } @@ -1497,7 +1507,7 @@ static int handle_request_update (listen_socket_t *sock, /* {{{ */ else ci->last_update_stamp = stamp; - temp = (char **) realloc (ci->values, + temp = (char **) rrd_realloc (ci->values, sizeof (char *) * (ci->values_num + 1)); if (temp == NULL) { @@ -1640,6 +1650,8 @@ static int handle_request (listen_socket_t *sock, /* {{{ */ return batch_start(sock); else if (strcasecmp (command, ".") == 0 && sock != NULL && sock->batch_start) return batch_done(sock); + else if (strcasecmp (command, "quit") == 0) + return -1; else return send_response(sock, RESP_ERR, "Unknown command: %s\n", command); @@ -1759,7 +1771,7 @@ static int journal_replay (const char *file) /* {{{ */ if (file == NULL) return 0; { - char *reason; + char *reason = "unknown error"; int status = 0; struct stat statbuf; @@ -1912,7 +1924,7 @@ static void *connection_thread_main (void *args) /* {{{ */ { pthread_t *temp; - temp = (pthread_t *) realloc (connection_threads, + temp = (pthread_t *) rrd_realloc (connection_threads, sizeof (pthread_t) * (connection_threads_num + 1)); if (temp == NULL) { @@ -2015,7 +2027,7 @@ out_close: connection_threads_num--; - temp = realloc(connection_threads, + temp = rrd_realloc(connection_threads, sizeof(*connection_threads) * connection_threads_num); if (connection_threads_num > 0 && temp == NULL) RRDD_LOG(LOG_ERR, "connection_thread_main: realloc(--) failed."); @@ -2039,7 +2051,7 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ if (strncmp(path, "unix:", strlen("unix:")) == 0) path += strlen("unix:"); - temp = (listen_socket_t *) realloc (listen_fds, + temp = (listen_socket_t *) rrd_realloc (listen_fds, sizeof (listen_fds[0]) * (listen_fds_num + 1)); if (temp == NULL) { @@ -2168,7 +2180,7 @@ static int open_listen_socket_network(const listen_socket_t *sock) /* {{{ */ listen_socket_t *temp; int one = 1; - temp = (listen_socket_t *) realloc (listen_fds, + temp = (listen_socket_t *) rrd_realloc (listen_fds, sizeof (listen_fds[0]) * (listen_fds_num + 1)); if (temp == NULL) { @@ -2514,7 +2526,7 @@ static int read_options (int argc, char **argv) /* {{{ */ } memset(new, 0, sizeof(listen_socket_t)); - temp = (listen_socket_t **) realloc (config_listen_address_list, + temp = (listen_socket_t **) rrd_realloc (config_listen_address_list, sizeof (listen_socket_t *) * (config_listen_address_list_len + 1)); if (temp == NULL) {