Skip to content

Commit

Permalink
Make sane variable names for cluster in memcached, check for max key …
Browse files Browse the repository at this point in the history
…length.
  • Loading branch information
jbuchbinder committed Jan 23, 2013
1 parent 6d6b312 commit c272c4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions gmetad/rrd_helpers.c
Expand Up @@ -319,13 +319,18 @@ push_data_to_carbon( char *graphite_msg)
} }


#ifdef WITH_MEMCACHED #ifdef WITH_MEMCACHED
#define MEMCACHED_MAX_KEY_LENGTH 256
int int
write_data_to_memcached ( const char *source, const char *host, const char *metric, write_data_to_memcached ( const char *cluster, const char *host, const char *metric,
const char *sum, unsigned int process_time, unsigned int expiry ) const char *sum, unsigned int process_time, unsigned int expiry )
{ {
time_t expiry_time; time_t expiry_time;
char s_path[256]; char s_path[MEMCACHED_MAX_KEY_LENGTH];
sprintf(s_path, "%s/%s/%s", source, host, metric); if (strlen(cluster) + strlen(host) + strlen(metric) + 2 > MEMCACHED_MAX_KEY_LENGTH) {
debug_msg("Cluster + host + metric + 2 > %d", MEMCACHED_MAX_KEY_LENGTH);
return EXIT_FAILURE;
}
sprintf(s_path, "%s/%s/%s", cluster, host, metric);


if (expiry != 0) { if (expiry != 0) {
expiry_time = time(NULL) + expiry; expiry_time = time(NULL) + expiry;
Expand Down
2 changes: 1 addition & 1 deletion gmetad/rrd_helpers.h
Expand Up @@ -12,7 +12,7 @@ write_data_to_rrd ( const char *source, const char *host, const char *metric,


#ifdef WITH_MEMCACHED #ifdef WITH_MEMCACHED
int int
write_data_to_memcached ( const char *source, const char *host, const char *metric, write_data_to_memcached ( const char *cluster, const char *host, const char *metric,
const char *sum, unsigned int process_time, unsigned int expiry ); const char *sum, unsigned int process_time, unsigned int expiry );
#endif /* WITH_MEMCACHED */ #endif /* WITH_MEMCACHED */


Expand Down

0 comments on commit c272c4b

Please sign in to comment.