-
Notifications
You must be signed in to change notification settings - Fork 0
/
rdma-consensus.h
78 lines (59 loc) · 1.88 KB
/
rdma-consensus.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef RDMA_CONSENSUS_H
#define RDMA_CONSENSUS_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#if HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#define RDMA_WRID 3
#define SHORT_SLEEP_DURATION 1
#include "ibv_layer.h"
#include "utils.h"
#include "leader-election.h"
int die(const char *reason);
void tcp_client_connect();
void tcp_server_listen();
void count_lines(const char* filename, struct global_context *ctx);
void parse_config(const char* filename, struct global_context *ctx);
bool compare_to_self(struct ifaddrs *ifaddr, char *addr);
void init_ctx_common(struct global_context* ctx, bool is_le);
void init_buf_le(struct global_context* ctx);
void init_buf_consensus(struct global_context* ctx);
void destroy_ctx(struct global_context* ctx, bool is_le);
void consensus_shutdown();
void emergency_shutdown(const char *reason);
static int wait_for_n( int n,
uint64_t round_nb,
struct global_context* ctx,
int num_entries,
struct ibv_wc *wc_array,
uint64_t* completed_ops ) {
int rc = wait_for_n_inner(n, round_nb, ctx, num_entries, wc_array, completed_ops);
if (rc < 0) { // unexpected error, shutdown
emergency_shutdown("Problem in wait_for_n");
}
return rc;
}
static void
post_send( struct ibv_qp* qp,
void* buf,
uint32_t len,
uint32_t lkey,
uint32_t rkey,
uint64_t remote_addr,
enum ibv_wr_opcode opcode,
uint64_t wrid,
bool signaled ) {
int rc = post_send_inner(qp, buf, len, lkey, rkey, remote_addr, opcode, wrid, signaled);
if (rc) { // there was a problem
emergency_shutdown("Problem in post_send");
}
}
#ifdef __cplusplus
}
#endif
#endif // RDMA_CONSENSUS_H