Skip to content

Commit

Permalink
move ping size to onwire and make name more clear
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Dec 14, 2012
1 parent 7a6f171 commit 8a9e295
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions libknet/handle.c
Expand Up @@ -97,12 +97,12 @@ knet_handle_t knet_handle_new(const struct knet_handle_cfg *knet_handle_cfg)

memset(knet_h->recv_from_links_buf, 0, KNET_DATABUFSIZE);

if ((knet_h->pingbuf = malloc(KNET_PINGBUFSIZE))== NULL) {
if ((knet_h->pingbuf = malloc(KNET_PING_SIZE))== NULL) {
log_err(knet_h, KNET_SUB_HANDLE, "Unable to allocate memory for hearbeat buffer");
goto exit_fail4;
}

memset(knet_h->pingbuf, 0, KNET_PINGBUFSIZE);
memset(knet_h->pingbuf, 0, KNET_PING_SIZE);

if ((pthread_rwlock_init(&knet_h->list_rwlock, NULL) != 0) ||
(pthread_rwlock_init(&knet_h->host_rwlock, NULL) != 0) ||
Expand Down Expand Up @@ -775,7 +775,7 @@ static void _handle_recv_from_links(knet_handle_t knet_h, int sockfd)

break;
case KNET_FRAME_PING:
outlen = KNET_PINGBUFSIZE;
outlen = KNET_PING_SIZE;
knet_h->recv_from_links_buf->kf_type = KNET_FRAME_PONG;
knet_h->recv_from_links_buf->kf_node = htons(knet_h->node_id);

Expand Down Expand Up @@ -996,7 +996,7 @@ static void _handle_dst_link_updates(knet_handle_t knet_h)
static void _handle_check_each(knet_handle_t knet_h, struct knet_host *dst_host, struct knet_link *dst_link)
{
int len;
ssize_t outlen = KNET_PINGBUFSIZE;
ssize_t outlen = KNET_PING_SIZE;
struct timespec clock_now, pong_last;
unsigned long long diff_ping;
unsigned char *outbuf = (unsigned char *)knet_h->pingbuf;
Expand All @@ -1019,7 +1019,7 @@ static void _handle_check_each(knet_handle_t knet_h, struct knet_host *dst_host,
if (knet_h->crypto_instance) {
if (crypto_encrypt_and_sign(knet_h,
(const unsigned char *)knet_h->pingbuf,
KNET_PINGBUFSIZE,
KNET_PING_SIZE,
knet_h->pingbuf_crypt,
&outlen) < 0) {
log_debug(knet_h, KNET_SUB_HB_T, "Unable to crypto ping packet");
Expand Down
2 changes: 0 additions & 2 deletions libknet/internals.h
Expand Up @@ -19,8 +19,6 @@
#define KNET_DATABUFSIZE 131072 /* 128k */
#define KNET_DATABUFSIZE_CRYPT KNET_DATABUFSIZE * 2

#define KNET_PINGBUFSIZE sizeof(struct knet_frame)

#define timespec_diff(start, end, diff) \
do { \
if (end.tv_sec > start.tv_sec) \
Expand Down
1 change: 1 addition & 0 deletions libknet/onwire.h
Expand Up @@ -73,6 +73,7 @@ struct knet_frame {
#define kf_time kf_payload.ping.kfd_time
#define kf_dyn kf_payload.ping.kfd_dyn

#define KNET_PING_SIZE sizeof(struct knet_frame)
#define KNET_FRAME_SIZE (sizeof(struct knet_frame) - sizeof(union knet_frame_data))

#define KNET_FRAME_VERSION 0x01
Expand Down

0 comments on commit 8a9e295

Please sign in to comment.