|
|
@ -1003,29 +1003,27 @@ static void send_client(cdata_t *cdata, const int64_t id, char *buf) |
|
|
|
|
|
|
|
|
|
|
|
/* Does this client accept compressed data? Only compress if it's
|
|
|
|
/* Does this client accept compressed data? Only compress if it's
|
|
|
|
* larger than one MTU. */ |
|
|
|
* larger than one MTU. */ |
|
|
|
if (client->gz && len > 1492) { |
|
|
|
if (client->gz) { |
|
|
|
unsigned long compsize; |
|
|
|
unsigned long compsize, decompsize = len; |
|
|
|
|
|
|
|
char *dest = ckalloc(len + 12); |
|
|
|
uint32_t msglen; |
|
|
|
uint32_t msglen; |
|
|
|
char *dest; |
|
|
|
|
|
|
|
int ret; |
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
|
|
compsize = round_up_page(len + 12); |
|
|
|
compsize = len; |
|
|
|
dest = ckalloc(compsize); |
|
|
|
|
|
|
|
compsize -= 12; |
|
|
|
|
|
|
|
ret = compress((Bytef *)dest + 12, &compsize, (Bytef *)buf, len); |
|
|
|
ret = compress((Bytef *)dest + 12, &compsize, (Bytef *)buf, len); |
|
|
|
if (unlikely(ret != Z_OK)) { |
|
|
|
if (unlikely(ret != Z_OK)) { |
|
|
|
LOGWARNING("Failed to gz compress in send_client, got %d sending uncompressed", ret); |
|
|
|
LOGINFO("Failed to gz compress in send_client, got %d sending uncompressed", ret); |
|
|
|
free(dest); |
|
|
|
free(dest); |
|
|
|
goto out; |
|
|
|
goto out; |
|
|
|
} |
|
|
|
} |
|
|
|
LOGDEBUG("Sending client message compressed %lu from %d", compsize, len); |
|
|
|
LOGDEBUG("Sending client message compressed %lu from %lu", compsize, decompsize); |
|
|
|
/* Copy gz magic header */ |
|
|
|
/* Copy gz magic header */ |
|
|
|
sprintf(dest, gzip_magic); |
|
|
|
sprintf(dest, gzip_magic); |
|
|
|
/* Copy compressed message length */ |
|
|
|
/* Copy compressed message length */ |
|
|
|
msglen = htole32(compsize); |
|
|
|
msglen = htole32(compsize); |
|
|
|
memcpy(dest + 4, &msglen, 4); |
|
|
|
memcpy(dest + 4, &msglen, 4); |
|
|
|
/* Copy decompressed message length */ |
|
|
|
/* Copy decompressed message length */ |
|
|
|
msglen = htole32(len); |
|
|
|
msglen = htole32(decompsize); |
|
|
|
memcpy(dest + 8, &msglen, 4); |
|
|
|
memcpy(dest + 8, &msglen, 4); |
|
|
|
len = compsize + 12; |
|
|
|
len = compsize + 12; |
|
|
|
free(buf); |
|
|
|
free(buf); |
|
|
|