Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F4511897
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/libknet/libknet-private.h b/libknet/libknet-private.h
index 5b49c936..44e6bb9e 100644
--- a/libknet/libknet-private.h
+++ b/libknet/libknet-private.h
@@ -1,25 +1,34 @@
#ifndef __KNETHANDLE_H__
#define __KNETHANDLE_H__
/* NOTE: you shouldn't need to include this header normally, it is provided for
* testing purpose only.
*/
#include "libknet.h"
+#define timespec_diff(start, end, diff) \
+do { \
+ if (end.tv_sec > start.tv_sec) \
+ *(diff) = ((end.tv_sec - start.tv_sec) * 1000000000llu) \
+ + end.tv_nsec - start.tv_nsec; \
+ else \
+ *(diff) = end.tv_nsec - start.tv_nsec; \
+} while (0);
+
struct knet_handle {
int sockfd;
int epollfd;
uint16_t node_id;
unsigned int enabled:1;
struct knet_host *host_head;
struct knet_host *host_index[KNET_MAX_HOST];
struct knet_listener *listener_head;
struct knet_frame *databuf;
struct knet_frame *pingbuf;
pthread_t control_thread;
pthread_t heartbt_thread;
pthread_rwlock_t list_rwlock;
};
#endif
diff --git a/tests/lookup_bench.c b/tests/lookup_bench.c
index 879624f7..fc027163 100644
--- a/tests/lookup_bench.c
+++ b/tests/lookup_bench.c
@@ -1,54 +1,55 @@
#include "config.h"
#include <stdlib.h>
#include <time.h>
#include "libknet.h"
+#include "libknet-private.h"
#include "netutils.h"
#include "utils.h"
#define KNET_PORT 50000
#define KNET_BENCH_LOOPNUM 100000000
int main(int argc, char *argv[])
{
struct knet_link *head;
struct sockaddr_in address;
struct timespec bench_start, bench_end;
unsigned long long i, bench_diff;
head = malloc(sizeof(struct knet_link));
if (head == NULL) {
log_error("Unable to create knet_link");
exit(EXIT_FAILURE);
}
memset(head, 0, sizeof(struct knet_link));
address.sin_family = AF_INET;
address.sin_port = htons(KNET_PORT);
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
memmove(&head->address, &address, sizeof(address));
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &bench_start);
for (i = 0; i < KNET_BENCH_LOOPNUM; i++) {
cmpaddr((struct sockaddr_storage *) &address, sizeof(address),
(struct sockaddr_storage *) &head->address,
sizeof(head->address));
}
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &bench_end);
printf("start sec: %3lu, nsec: %9lu\n end sec: %3lu, nsec: %9lu\n",
bench_start.tv_sec, bench_start.tv_nsec,
bench_end.tv_sec, bench_end.tv_nsec);
timespec_diff(bench_start, bench_end, &bench_diff);
printf("end - start = %llums\n", bench_diff);
return 0;
}
diff --git a/tests/utils_test.c b/tests/utils_test.c
index f69bbadc..860dd666 100644
--- a/tests/utils_test.c
+++ b/tests/utils_test.c
@@ -1,47 +1,48 @@
#include "config.h"
#include <time.h>
#include <stdlib.h>
#include "utils.h"
+#include "libknet-private.h"
#define timespec_set(x, sec, nsec) \
do { \
x.tv_sec = sec; \
x.tv_nsec = nsec; \
} while (0);
static void check_timespec_diff(void)
{
unsigned long long diff;
struct timespec start, end;
timespec_set(start, 1, 30000);
timespec_set(end, start.tv_sec, start.tv_nsec + 10000);
timespec_diff(start, end, &diff);
log_info("Checking 10000 == %llu", diff);
if (diff != 10000) {
log_error("Failure!");
exit(EXIT_FAILURE);
}
timespec_set(end, start.tv_sec + 5, start.tv_nsec - 5000);
timespec_diff(start, end, &diff);
log_info("Checking 4999995000 == %llu", diff);
if (diff != 4999995000llu) {
log_error("Failure!");
exit(EXIT_FAILURE);
}
}
int main(int argc, char *argv[])
{
check_timespec_diff();
return 0;
}
diff --git a/utils.h b/utils.h
index d91d5be9..5b38426e 100644
--- a/utils.h
+++ b/utils.h
@@ -1,43 +1,34 @@
#ifndef __UTILS_H__
#define __UTILS_H__
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <syslog.h>
extern int utils_debug;
extern int utils_syslog;
#define log_debug(fmt, args...) \
do { \
if (utils_debug) { \
printf("DEBUG(%s:%i|%s): " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##args); \
if (utils_syslog) syslog(LOG_DEBUG, "DEBUG(%s:%i|%s): " fmt, __FILE__, __LINE__, __FUNCTION__, ##args); \
} \
} while (0);
#define log_info(fmt, args...) \
do { \
fprintf(stderr, "Notice: " fmt "\n", ##args); \
if (utils_syslog) syslog(LOG_INFO, fmt, ##args); \
} while (0);
#define log_error(fmt, args...) \
do { \
fprintf(stderr, "Error: " fmt " (%s)\n", ##args, strerror(errno)); \
if (utils_syslog) syslog(LOG_ERR, fmt, ##args); \
} while (0);
-#define timespec_diff(start, end, diff) \
-do { \
- if (end.tv_sec > start.tv_sec) \
- *(diff) = ((end.tv_sec - start.tv_sec) * 1000000000llu) \
- + end.tv_nsec - start.tv_nsec; \
- else \
- *(diff) = end.tv_nsec - start.tv_nsec; \
-} while (0);
-
int knet_fdset_cloexec(int fd);
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jun 25, 3:13 AM (20 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1951967
Default Alt Text
(4 KB)
Attached To
Mode
rK kronosnet
Attached
Detach File
Event Timeline
Log In to Comment