if(!cv) cv = config_value_create(co, name, value);
else {
if(((cv->flags & CONFIG_VALUE_USED) && overwrite_used) || !(cv->flags & CONFIG_VALUE_USED)) {
- debug(D_CONFIG, "Overwriting '%s/%s'.", line, co->name, cv->name);
+ debug(D_CONFIG, "Line %d, overwriting '%s/%s'.", line, co->name, cv->name);
free(cv->value);
cv->value = strdup(value);
if(!cv->value) fatal("Cannot allocate config.value");
allocations.allocated -= old_size;
debug(D_MEMORY, "MEMORY: Re-allocated from %zu to %zu bytes for %s/%u@%s."
- " Status: allocated %z in %zu allocs."
+ " Status: allocated %zu in %zu allocs."
, old_size, size
, function, line, file
, allocations.allocated
struct target *n = get_apps_groups_target(s, w);
if(!n) {
- error("Cannot create target '%s' (line %d, word %d)", s, line, word);
+ error("Cannot create target '%s' (line %lu, word %lu)", s, line, word);
continue;
}
#ifdef MADV_MERGEABLE
}
else {
+/*
+ // test - load the file into memory
+ mem = calloc(1, size);
+ if(mem) {
+ if(lseek(fd, 0, SEEK_SET) == 0) {
+ if(read(fd, mem, size) != (ssize_t)size)
+ error("Cannot read from file '%s'", filename);
+ }
+ else
+ error("Cannot seek to beginning of file '%s'.", filename);
+ }
+*/
mem = mmap(NULL, size, PROT_READ|PROT_WRITE, flags|MAP_ANONYMOUS, -1, 0);
if(mem != MAP_FAILED) {
if(lseek(fd, 0, SEEK_SET) == 0) {
debug(D_DICTIONARY, "Creating name value entry for name '%s'.", name);
NAME_VALUE *nv = calloc(1, sizeof(NAME_VALUE));
- if(unlikely(!nv)) fatal("Cannot allocate name_value of size %z", sizeof(NAME_VALUE));
+ if(unlikely(!nv)) fatal("Cannot allocate name_value of size %zu", sizeof(NAME_VALUE));
if(dict->flags & DICTIONARY_FLAG_NAME_LINK_DONT_CLONE)
nv->name = (char *)name;
else {
nv->name = strdup(name);
if (unlikely(!nv->name))
- fatal("Cannot allocate name_value.name of size %z", strlen(name));
+ fatal("Cannot allocate name_value.name of size %zu", strlen(name));
}
nv->hash = (hash)?hash:simple_hash(nv->name);
else {
nv->value = malloc(value_len);
if (unlikely(!nv->value))
- fatal("Cannot allocate name_value.value of size %z", value_len);
+ fatal("Cannot allocate name_value.value of size %zu", value_len);
memcpy(nv->value, value, value_len);
}
*old = nv->value;
if(unlikely(!nv->value))
- fatal("Cannot allocate value of size %z", value_len);
+ fatal("Cannot allocate value of size %zu", value_len);
memcpy(value, value, value_len);
nv->value = value;
#define fatal(args...) fatal_int(__FILE__, __FUNCTION__, __LINE__, ##args)
extern void log_date(FILE *out);
-extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... );
-extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn));
-extern void log_access( const char *fmt, ... );
+extern void debug_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
+extern void info_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 4, 5)));
+extern void error_int( const char *prefix, const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ (( format (printf, 5, 6)));
+extern void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) __attribute__ ((noreturn, format (printf, 4, 5)));
+extern void log_access( const char *fmt, ... ) __attribute__ (( format (printf, 1, 2)));
#endif /* NETDATA_LOG_H */
else if(!strcmp(s, "fixed"))
web_gzip_strategy = Z_FIXED;
else {
- error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.");
+ error("Invalid compression strategy '%s'. Valid strategies are 'default', 'filtered', 'huffman only', 'rle' and 'fixed'. Proceeding with 'default'.", s);
web_gzip_strategy = Z_DEFAULT_STRATEGY;
}
web_gzip_level = (int)config_get_number("global", "web compression level", 3);
if(web_gzip_level < 1) {
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).");
+ error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 1 (fastest compression).", web_gzip_level);
web_gzip_level = 1;
}
else if(web_gzip_level > 9) {
- error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).");
+ error("Invalid compression level %d. Valid levels are 1 (fastest) to 9 (best ratio). Proceeding with level 9 (best compression).", web_gzip_level);
web_gzip_level = 9;
}
#endif /* NETDATA_WITH_ZLIB */
RRDDIM *rd = rrddim_find(st, c->id);
if(!rd) {
- debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s'", st->id, c->id, c->name);
+ debug(D_TC_LOOP, "TC: Adding to chart '%s', dimension '%s' (name: '%s')", st->id, c->id, c->name);
// new class, we have to add it
rd = rrddim_add(st, c->id, c->name?c->name:c->id, 8, 1024, RRDDIM_INCREMENTAL);
sleep((unsigned int) (cd->update_every * 10));
}
else {
- error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). We tried %d times to restart it, but it failed to generate data. Disabling it.", cd->fullfilename, code, cd->successful_collections, cd->serial_failures);
+ error("PLUGINSD: '%s' exited with error code %d, but has given useful output in the past (%zu times). We tried %zu times to restart it, but it failed to generate data. Disabling it.", cd->fullfilename, code, cd->successful_collections, cd->serial_failures);
cd->enabled = 0;
}
}
sleep((unsigned int) (cd->update_every * 10));
}
else {
- error("PLUGINSD: '%s' (pid %d) does not generate useful output, although it reports success (exits with 0), but we have tried %d times to collect something. Disabling it.", cd->fullfilename, cd->pid, cd->serial_failures);
+ error("PLUGINSD: '%s' (pid %d) does not generate useful output, although it reports success (exits with 0), but we have tried %zu times to collect something. Disabling it.", cd->fullfilename, cd->pid, cd->serial_failures);
cd->enabled = 0;
}
}
if(!ff) return 0; // we return 0, so that we will retry to open it next time
// make sure we have 3 lines
- unsigned long lines = procfile_lines(ff), l;
+ size_t lines = procfile_lines(ff), l;
if(lines < 2) {
- error("/proc/net/stat/synproxy has %d lines, expected no less than 2. Disabling it.", lines);
+ error("/proc/net/stat/synproxy has %zu lines, expected no less than 2. Disabling it.", lines);
return 1;
}
debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): allocating %zu bytes", url, sizeof(URL) + urllen);
URL *u = malloc(sizeof(URL) + urllen);
- if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen);
+ if(!u) fatal("Cannot allocate %zu bytes for URL '%s'", sizeof(URL) + urllen, url);
// a simple strcpy() should do the job
// but I prefer to be safe, since the caller specified urllen
// verify it is valid
if (unlikely(len < 85 || s[1] != '\t' || s[10] != '\t' || s[47] != '\t' || s[84] != '\t')) {
- error("Registry: log line %u is wrong (len = %zu).", line, len);
+ error("Registry: log line %zu is wrong (len = %zu).", line, len);
continue;
}
s[1] = s[10] = s[47] = s[84] = '\0';
char *url = name;
while(*url && *url != '\t') url++;
if(!*url) {
- error("Registry: log line %u does not have a url.", line);
+ error("Registry: log line %zu does not have a url.", line);
continue;
}
*url++ = '\0';
switch(*s) {
case 'T': // totals
if(unlikely(len != 103 || s[1] != '\t' || s[18] != '\t' || s[35] != '\t' || s[52] != '\t' || s[69] != '\t' || s[86] != '\t' || s[103] != '\0')) {
- error("Registry totals line %u is wrong (len = %zu).", line, len);
+ error("Registry totals line %zu is wrong (len = %zu).", line, len);
continue;
}
registry.persons_count = strtoull(&s[2], NULL, 16);
m = NULL;
// verify it is valid
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
- error("Registry person line %u is wrong (len = %zu).", line, len);
+ error("Registry person line %zu is wrong (len = %zu).", line, len);
continue;
}
p = NULL;
// verify it is valid
if(unlikely(len != 65 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[65] != '\0')) {
- error("Registry person line %u is wrong (len = %zu).", line, len);
+ error("Registry person line %zu is wrong (len = %zu).", line, len);
continue;
}
// verify it is valid
if(len < 69 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t' || s[68] != '\t') {
- error("Registry person URL line %u is wrong (len = %zu).", line, len);
+ error("Registry person URL line %zu is wrong (len = %zu).", line, len);
continue;
}
char *url = &s[69];
while(*url && *url != '\t') url++;
if(!*url) {
- error("Registry person URL line %u does not have a url.", line);
+ error("Registry person URL line %zu does not have a url.", line);
continue;
}
*url++ = '\0';
// verify it is valid
if(len < 32 || s[1] != '\t' || s[10] != '\t' || s[19] != '\t' || s[28] != '\t' || s[31] != '\t') {
- error("Registry person URL line %u is wrong (len = %zu).", line, len);
+ error("Registry person URL line %zu is wrong (len = %zu).", line, len);
continue;
}
// check if we will re-write the entire data set
if(unlikely(usecdiff(&st->last_collected_time, &st->last_updated) > st->update_every * st->entries * 1000000ULL)) {
- info("%s: too old data (last updated at %u.%u, last collected at %u.%u). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
+ info("%s: too old data (last updated at %zu.%zu, last collected at %zu.%zu). Reseting it. Will not store the next entry.", st->name, st->last_updated.tv_sec, st->last_updated.tv_usec, st->last_collected_time.tv_sec, st->last_collected_time.tv_usec);
rrdset_reset(st);
st->usec_since_last_update = st->update_every * 1000000ULL;
long c; // current line ( -1 ~ n ), ( -1 = none, use rrdr_rows() to get number of rows )
long group; // how many collected values were grouped for each row
- long update_every; // what is the suggested update frequency in seconds
+ int update_every; // what is the suggested update frequency in seconds
calculated_number min;
calculated_number max;
, kq, kq, sq, r->st->name, sq
, kq, kq, r->update_every
, kq, kq, r->st->update_every
- , kq, kq, rrdset_first_entry_t(r->st)
- , kq, kq, rrdset_last_entry_t(r->st)
- , kq, kq, r->before
- , kq, kq, r->after
+ , kq, kq, (uint32_t)rrdset_first_entry_t(r->st)
+ , kq, kq, (uint32_t)rrdset_last_entry_t(r->st)
+ , kq, kq, (uint32_t)r->before
+ , kq, kq, (uint32_t)r->after
, kq, kq);
for(c = 0, i = 0, rd = r->st->dimensions; rd && c < r->d ;c++, rd = rd->next) {
}
buffer_sprintf(wb, "],\n"
- " %sdimensions%s: %d,\n"
- " %spoints%s: %d,\n"
+ " %sdimensions%s: %ld,\n"
+ " %spoints%s: %ld,\n"
" %sformat%s: %s"
, kq, kq, i
, kq, kq, rows
snprintfz(overflow_annotation, 200, ",{%sv%s:%sRESET OR OVERFLOW%s},{%sv%s:%sThe counters have been wrapped.%s}", kq, kq, sq, sq, kq, kq, sq, sq);
snprintfz(normal_annotation, 200, ",{%sv%s:null},{%sv%s:null}", kq, kq, kq, kq);
- buffer_sprintf(wb, "{\n %scols%s:\n [\n", kq, kq, kq, kq);
+ buffer_sprintf(wb, "{\n %scols%s:\n [\n", kq, kq);
buffer_sprintf(wb, " {%sid%s:%s%s,%slabel%s:%stime%s,%spattern%s:%s%s,%stype%s:%sdatetime%s},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq);
buffer_sprintf(wb, " {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotation%s}},\n", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
buffer_sprintf(wb, " {%sid%s:%s%s,%slabel%s:%s%s,%spattern%s:%s%s,%stype%s:%sstring%s,%sp%s:{%srole%s:%sannotationText%s}}", kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, sq, sq, kq, kq, kq, kq, sq, sq);
return r;
cleanup:
- error("Cannot allocate RRDR memory for %d entries", n);
+ error("Cannot allocate RRDR memory for %ld entries", n);
if(likely(r)) rrdr_free(r);
return NULL;
}
#ifdef NETDATA_INTERNAL_CHECKS
if(after_new < first_entry_t) {
- error("after_new %u is too small, minimum %u", after_new, first_entry_t);
+ error("after_new %u is too small, minimum %u", (uint32_t)after_new, (uint32_t)first_entry_t);
}
if(after_new > last_entry_t) {
- error("after_new %u is too big, maximum %u", after_new, last_entry_t);
+ error("after_new %u is too big, maximum %u", (uint32_t)after_new, (uint32_t)last_entry_t);
}
if(before_new < first_entry_t) {
- error("before_new %u is too small, minimum %u", before_new, first_entry_t);
+ error("before_new %u is too small, minimum %u", (uint32_t)before_new, (uint32_t)first_entry_t);
}
if(before_new > last_entry_t) {
- error("before_new %u is too big, maximum %u", before_new, last_entry_t);
+ error("before_new %u is too big, maximum %u", (uint32_t)before_new, (uint32_t)last_entry_t);
}
if(start_at_slot < 0 || start_at_slot >= st->entries) {
- error("start_at_slot is invalid %ld, expected %ld to %ld", start_at_slot, 0, st->entries - 1);
+ error("start_at_slot is invalid %ld, expected 0 to %ld", start_at_slot, st->entries - 1);
}
if(stop_at_slot < 0 || stop_at_slot >= st->entries) {
- error("stop_at_slot is invalid %ld, expected %ld to %ld", stop_at_slot, 0, st->entries - 1);
+ error("stop_at_slot is invalid %ld, expected 0 to %ld", stop_at_slot, st->entries - 1);
}
if(points_new > (before_new - after_new) / group / st->update_every + 1) {
error("points_new %ld is more than points %ld", points_new, (before_new - after_new) / group / st->update_every + 1);
RRDR *r = rrdr_create(st, points);
if(!r) {
#ifdef NETDATA_INTERNAL_CHECKS
- error("Cannot create RRDR for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
+ error("Cannot create RRDR for %s, after=%u, before=%u, duration=%u, points=%ld", st->id, (uint32_t)after, (uint32_t)before, (uint32_t)duration, points);
#endif
return NULL;
}
if(!r->d) {
#ifdef NETDATA_INTERNAL_CHECKS
- error("Returning empty RRDR (no dimensions in RRDSET) for %s, after=%u, before=%u, duration=%u, points=%d", st->id, after, before, duration, points);
+ error("Returning empty RRDR (no dimensions in RRDSET) for %s, after=%u, before=%u, duration=%u, points=%ld", st->id, (uint32_t)after, (uint32_t)before, (uint32_t)duration, points);
#endif
return r;
}
// -------------------------------------------------------------------------
// checks for debugging
- if(debug) debug(D_RRD_STATS, "INFO %s first_t: %lu, last_t: %lu, all_duration: %lu, after: %lu, before: %lu, duration: %lu, points: %ld, group: %ld"
+ if(debug) debug(D_RRD_STATS, "INFO %s first_t: %u, last_t: %u, all_duration: %u, after: %u, before: %u, duration: %u, points: %ld, group: %ld"
, st->id
- , first_entry_t
- , last_entry_t
- , last_entry_t - first_entry_t
- , after
- , before
- , duration
+ , (uint32_t)first_entry_t
+ , (uint32_t)last_entry_t
+ , (uint32_t)(last_entry_t - first_entry_t)
+ , (uint32_t)after
+ , (uint32_t)before
+ , (uint32_t)duration
, points
, group
);
dt = st->update_every,
group_start_t = 0;
- if(unlikely(debug)) debug(D_RRD_STATS, "BEGIN %s after_t: %lu (stop_at_t: %ld), before_t: %lu (start_at_t: %ld), start_t(now): %lu, current_entry: %ld, entries: %ld"
+ if(unlikely(debug)) debug(D_RRD_STATS, "BEGIN %s after_t: %u (stop_at_t: %ld), before_t: %u (start_at_t: %ld), start_t(now): %u, current_entry: %ld, entries: %ld"
, st->id
- , after
+ , (uint32_t)after
, stop_at_slot
- , before
+ , (uint32_t)before
, start_at_slot
- , now
+ , (uint32_t)now
, st->current_entry
, st->entries
);
long count = 0, printed = 0, group_count = 0;
last_timestamp = 0;
- if(st->debug) debug(D_RRD_STATS, "%s: REQUEST after:%lu before:%lu, points:%d, group:%d, CHART cur:%ld first: %lu last:%lu, CALC start_t:%ld, stop_t:%ld"
+ if(st->debug) debug(D_RRD_STATS, "%s: REQUEST after:%u before:%u, points:%ld, group:%ld, CHART cur:%ld first: %u last:%u, CALC start_t:%ld, stop_t:%ld"
, st->id
- , after
- , before
+ , (uint32_t)after
+ , (uint32_t)before
, points
, group
, st->current_entry
- , rrdset_first_entry_t(st)
- , rrdset_last_entry_t(st)
+ , (uint32_t)rrdset_first_entry_t(st)
+ , (uint32_t)rrdset_last_entry_t(st)
, t
, stop_at_t
);
ca->cpu_percpu = malloc(sizeof(unsigned long long) * i);
if(!ca->cpu_percpu)
- fatal("Cannot allocate memory (%z bytes)", sizeof(unsigned long long) * i);
+ fatal("Cannot allocate memory (%zu bytes)", sizeof(unsigned long long) * i);
ca->cpus = i;
}
buffer_overflow_check(wb);
}
-BUFFER *buffer_create(long size)
+BUFFER *buffer_create(size_t size)
{
BUFFER *b;
- debug(D_WEB_BUFFER, "Creating new web buffer of size %d.", size);
+ debug(D_WEB_BUFFER, "Creating new web buffer of size %zu.", size);
b = calloc(1, sizeof(BUFFER));
if(!b) {
b->buffer = malloc(size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
if(!b->buffer) {
- error("Cannot allocate a buffer of size %u.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
+ error("Cannot allocate a buffer of size %zu.", size + sizeof(BUFFER_OVERFLOW_EOF) + 2);
free(b);
return NULL;
}
{
buffer_overflow_check(b);
- debug(D_WEB_BUFFER, "Freeing web buffer of size %d.", b->size);
+ debug(D_WEB_BUFFER, "Freeing web buffer of size %zu.", b->size);
if(b->buffer) free(b->buffer);
free(b);
size_t increase = free_size_required - left;
if(increase < WEB_DATA_LENGTH_INCREASE_STEP) increase = WEB_DATA_LENGTH_INCREASE_STEP;
- debug(D_WEB_BUFFER, "Increasing data buffer from size %d to %d.", b->size, b->size + increase);
+ debug(D_WEB_BUFFER, "Increasing data buffer from size %zu to %zu.", b->size, b->size + increase);
b->buffer = realloc(b->buffer, b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
if(!b->buffer)
- fatal("Failed to increase data buffer from size %d to %d.",
+ fatal("Failed to increase data buffer from size %zu to %zu.",
b->size + sizeof(BUFFER_OVERFLOW_EOF) + 2,
b->size + increase + sizeof(BUFFER_OVERFLOW_EOF) + 2);
extern void buffer_date(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
extern void buffer_jsdate(BUFFER *wb, int year, int month, int day, int hours, int minutes, int seconds);
-extern BUFFER *buffer_create(long size);
+extern BUFFER *buffer_create(size_t size);
extern void buffer_free(BUFFER *b);
extern void buffer_increase(BUFFER *b, size_t free_size_required);
-extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...);
+extern void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...) __attribute__ (( format (printf, 3, 4)));
extern void buffer_vsprintf(BUFFER *wb, const char *fmt, va_list args);
-extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...);
+extern void buffer_sprintf(BUFFER *wb, const char *fmt, ...) __attribute__ (( format (printf, 2, 3)));
extern void buffer_char_replace(BUFFER *wb, char from, char to);
buffer_strcat(w->response.header_output, "\r\n");
// sent the HTTP header
- debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %d: '%s'"
+ debug(D_WEB_DATA, "%llu: Sending response HTTP header of size %zu: '%s'"
, w->id
, buffer_strlen(w->response.header_output)
, buffer_tostring(w->response.header_output)
if(bytes > 0)
w->stats_sent_bytes += bytes;
- debug(D_WEB_CLIENT, "%llu: HTTP Header failed to be sent (I sent %d bytes but the system sent %d bytes). Closing web client.", w->id,
- buffer_strlen(w->response.header_output), bytes);
+ debug(D_WEB_CLIENT, "%llu: HTTP Header failed to be sent (I sent %zu bytes but the system sent %zd bytes). Closing web client."
+ , w->id
+ , buffer_strlen(w->response.header_output)
+ , bytes);
WEB_CLIENT_IS_DEAD(w);
return;
// pretty logging
switch(w->mode) {
case WEB_CLIENT_MODE_OPTIONS:
- debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
+ debug(D_WEB_CLIENT, "%llu: Done preparing the OPTIONS response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
break;
case WEB_CLIENT_MODE_NORMAL:
- debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%d bytes) to client.", w->id, w->response.data->len);
+ debug(D_WEB_CLIENT, "%llu: Done preparing the response. Sending data (%zu bytes) to client.", w->id, w->response.data->len);
break;
case WEB_CLIENT_MODE_FILECOPY:
if(w->response.rlen) {
- debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %d bytes to client.", w->id, w->response.rlen);
+ debug(D_WEB_CLIENT, "%llu: Done preparing the response. Will be sending data file of %zu bytes to client.", w->id, w->response.rlen);
w->wait_receive = 1;
/*
ssize_t web_client_send_chunk_header(struct web_client *w, size_t len)
{
- debug(D_DEFLATE, "%llu: OPEN CHUNK of %d bytes (hex: %x).", w->id, len, len);
+ debug(D_DEFLATE, "%llu: OPEN CHUNK of %zu bytes (hex: %zx).", w->id, len, len);
char buf[24];
sprintf(buf, "%zX\r\n", len);
ssize_t bytes = send(w->ofd, buf, strlen(buf), 0);
if(bytes > 0) {
- debug(D_DEFLATE, "%llu: Sent chunk header %d bytes.", w->id, bytes);
+ debug(D_DEFLATE, "%llu: Sent chunk header %zd bytes.", w->id, bytes);
w->stats_sent_bytes += bytes;
}
ssize_t bytes = send(w->ofd, "\r\n", 2, 0);
if(bytes > 0) {
- debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
+ debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
w->stats_sent_bytes += bytes;
}
ssize_t bytes = send(w->ofd, "\r\n0\r\n\r\n", 7, 0);
if(bytes > 0) {
- debug(D_DEFLATE, "%llu: Sent chunk suffix %d bytes.", w->id, bytes);
+ debug(D_DEFLATE, "%llu: Sent chunk suffix %zd bytes.", w->id, bytes);
w->stats_sent_bytes += bytes;
}
// when using compression,
// w->response.sent is the amount of bytes passed through compression
- debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %d, w->response.sent = %d, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %d, w->response.zstream.avail_out = %d, w->response.zstream.total_in = %d, w->response.zstream.total_out = %d.",
+ debug(D_DEFLATE, "%llu: web_client_send_deflate(): w->response.data->len = %zu, w->response.sent = %zu, w->response.zhave = %zu, w->response.zsent = %zu, w->response.zstream.avail_in = %d, w->response.zstream.avail_out = %d, w->response.zstream.total_in = %lu, w->response.zstream.total_out = %lu.",
w->id, w->response.data->len, w->response.sent, w->response.zhave, w->response.zsent, w->response.zstream.avail_in, w->response.zstream.avail_out, w->response.zstream.total_in, w->response.zstream.total_out);
if(w->response.data->len - w->response.sent == 0 && w->response.zstream.avail_in == 0 && w->response.zhave == w->response.zsent && w->response.zstream.avail_out != 0) {
if(t < 0) return t;
}
- debug(D_DEFLATE, "%llu: Compressing %d new bytes starting from %d (and %d left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in);
+ debug(D_DEFLATE, "%llu: Compressing %zu new bytes starting from %zu (and %u left behind).", w->id, (w->response.data->len - w->response.sent), w->response.sent, w->response.zstream.avail_in);
// give the compressor all the data not passed through the compressor yet
if(w->response.data->len > w->response.sent) {
// keep track of the bytes passed through the compressor
w->response.sent = w->response.data->len;
- debug(D_DEFLATE, "%llu: Compression produced %d bytes.", w->id, w->response.zhave);
+ debug(D_DEFLATE, "%llu: Compression produced %zu bytes.", w->id, w->response.zhave);
// open a new chunk
ssize_t t2 = web_client_send_chunk_header(w, w->response.zhave);
t += t2;
}
- debug(D_WEB_CLIENT, "%llu: Sending %d bytes of data (+%d of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
+ debug(D_WEB_CLIENT, "%llu: Sending %zu bytes of data (+%zd of chunk header).", w->id, w->response.zhave - w->response.zsent, t);
len = send(w->ofd, &w->response.zbuffer[w->response.zsent], (size_t) (w->response.zhave - w->response.zsent), MSG_DONTWAIT);
if(len > 0) {
w->stats_sent_bytes += len;
w->response.zsent += len;
len += t;
- debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, len);
+ debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, len);
}
else if(len == 0) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client (zhave = %zu, zsent = %zu, need to send = %zu).",
w->id, w->response.zhave, w->response.zsent, w->response.zhave - w->response.zsent);
-
+
WEB_CLIENT_IS_DEAD(w);
}
else {
if(likely(bytes > 0)) {
w->stats_sent_bytes += bytes;
w->response.sent += bytes;
- debug(D_WEB_CLIENT, "%llu: Sent %d bytes.", w->id, bytes);
+ debug(D_WEB_CLIENT, "%llu: Sent %zu bytes.", w->id, bytes);
}
else if(likely(bytes == 0)) {
debug(D_WEB_CLIENT, "%llu: Did not send any bytes to the client.", w->id);
w->response.data->len += bytes;
w->response.data->buffer[w->response.data->len] = '\0';
- debug(D_WEB_CLIENT, "%llu: Received %d bytes.", w->id, bytes);
+ debug(D_WEB_CLIENT, "%llu: Received %zu bytes.", w->id, bytes);
debug(D_WEB_DATA, "%llu: Received data: '%s'.", w->id, &w->response.data->buffer[old]);
if(w->mode == WEB_CLIENT_MODE_FILECOPY) {
break;
}
else if(unlikely(!w->wait_receive && !w->wait_send)) {
- debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.");
+ debug(D_WEB_CLIENT, "%llu: client is not set for neither receiving nor sending data.", w->id);
break;
}
sleep(5);
create_listen_socket();
if(listen_fd < 0)
- fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
+ fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
failures = 0;
}
}
if(pthread_create(&w->thread, NULL, web_client_main, w) != 0) {
- error("%llu: failed to create new thread for web client.");
+ error("%llu: failed to create new thread for web client.", w->id);
w->obsolete = 1;
}
else if(pthread_detach(w->thread) != 0) {
create_listen_socket();
if(listen_fd < 0 || listen_fd >= FD_SETSIZE)
- fatal("Cannot listen for web clients (connected clients %llu).", global_statistics.connected_clients);
+ fatal("Cannot listen for web clients (connected clients %lu).", global_statistics.connected_clients);
FD_ZERO (&ifds);
FD_ZERO (&ofds);