Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
clsync
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-10-08 19:35:51 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e5028b9d0cba7a7420fc5880193465913a9042f7
e5028b9d
1 parent
ef649cbe
[cluster] more tiny fixes of messages receiving/sending
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
23 deletions
calc.c
calc.h
cluster.c
cluster.h
error.h
main.c
malloc.c
calc.c
View file @
e5028b9
...
...
@@ -17,7 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common.h"
#include "calc.h"
#include "error.h"
#ifdef HAVE_MHASH
#include <mhash.h>
...
...
@@ -36,7 +39,13 @@
// Copied from http://en.wikipedia.org/wiki/Adler-32
uint32_t
adler32_calc
(
const
unsigned
char
*
const
data
,
uint32_t
len
)
{
// where data is the location of the data in physical
// memory and len is the length of the data in bytes
// memory and len is the length of the data in bytes
if
(
len
&
3
)
warning
(
"len [%i] & 3 == %i != 0. Wrong length (not a multiple of 4)."
,
len
,
len
&
3
);
debug
(
70
,
"%p, %i"
,
data
,
len
);
const
int
MOD_ADLER
=
65521
;
uint32_t
a
=
1
,
b
=
0
;
int32_t
index
;
...
...
@@ -44,6 +53,7 @@ uint32_t adler32_calc(const unsigned char *const data, uint32_t len) { // where
// Process each byte of the data in order
for
(
index
=
0
;
index
<
len
;
++
index
)
{
debug
(
80
,
"%5i: %02x %02x %02x"
,
index
,
data
[
index
],
a
,
b
);
a
=
(
a
+
data
[
index
])
%
MOD_ADLER
;
b
=
(
b
+
a
)
%
MOD_ADLER
;
}
...
...
calc.h
View file @
e5028b9
...
...
@@ -24,6 +24,7 @@
static
inline
uint32_t
adler32_calc
(
const
unsigned
char
*
const
data
,
uint32_t
len
)
{
uint32_t
adler32
;
debug
(
70
,
"%p, %i -> mhash"
,
data
,
len
);
MHASH
td
=
mhash_init
(
MHASH_ADLER32
);
mhash
(
td
,
data
,
len
);
...
...
cluster.c
View file @
e5028b9
This diff is collapsed. Click to expand it.
cluster.h
View file @
e5028b9
...
...
@@ -68,10 +68,10 @@
// Types
enum
adler32_calc
{
ADLER32_CALC_NONE
=
0x00
,
ADLER32_CALC_NONE
=
0x00
,
ADLER32_CALC_HEADER
=
0x01
,
ADLER32_CALC_DATA
=
0x02
,
ADLER32_CALC_ALL
=
0x03
,
ADLER32_CALC_DATA
=
0x02
,
ADLER32_CALC_ALL
=
0x03
,
};
typedef
enum
adler32_calc
adler32_calc_t
;
...
...
@@ -149,7 +149,7 @@ typedef struct clustercmd_ack clustercmd_ack_t;
enum
reject_reason
{
REJ_UNKNOWN
=
0
,
REJ_
adler
32MISMATCH
,
REJ_
ADLER
32MISMATCH
,
};
typedef
enum
reject_reason
reject_reason_t
;
...
...
@@ -167,8 +167,8 @@ struct clustercmd_ht_exch {
typedef
struct
clustercmd_ht_exch
clustercmd_ht_exch_t
;
struct
clustercmdadler32
{
uint32_t
hdr
;
uint32_t
dat
;
uint32_t
hdr
;
// 32
uint32_t
dat
;
// 64
};
typedef
struct
clustercmdadler32
clustercmdadler32_t
;
...
...
@@ -177,10 +177,10 @@ struct clustercmdhdr { // bits
uint8_t
src_node_id
;
// 16
uint8_t
flags
;
// 24 (for future compatibility)
uint8_t
cmd_id
;
// 32
clustercmdadler32_t
adler32
;
//
64
uint32_t
data_len
;
//
96
uint32_t
ts
;
// 1
28
uint32_t
serial
;
// 1
60
clustercmdadler32_t
adler32
;
//
96
uint32_t
data_len
;
//
128
uint32_t
ts
;
// 1
60
uint32_t
serial
;
// 1
92
};
typedef
struct
clustercmdhdr
clustercmdhdr_t
;
...
...
error.h
View file @
e5028b9
...
...
@@ -30,7 +30,7 @@
extern
void
_critical
(
const
char
*
const
function_name
,
const
char
*
fmt
,
...);
#define critical(...) _critical(__FUNCTION__, __VA_ARGS__)
#define critical_on(cond) {debug(30, "%s", TOSTR(cond)); if (unlikely(cond)) {critical("Assert: "TOSTR(cond));}}
#define critical_on(cond) {debug(30, "
critical_on: checking:
%s", TOSTR(cond)); if (unlikely(cond)) {critical("Assert: "TOSTR(cond));}}
extern
void
_error
(
const
char
*
const
function_name
,
const
char
*
fmt
,
...);
#define error(...) _error(__FUNCTION__, __VA_ARGS__)
...
...
main.c
View file @
e5028b9
...
...
@@ -1921,7 +1921,7 @@ int ctx_check(ctx_t *ctx_p) {
if
(
ctx_p
->
cluster_nodename
==
NULL
)
{
if
(
!
uname
(
&
utsname
))
ctx_p
->
cluster_nodename
=
utsname
.
nodename
;
ctx_p
->
cluster_nodename
=
strdup
(
utsname
.
nodename
)
;
debug
(
1
,
"cluster node name is: %s"
,
ctx_p
->
cluster_nodename
);
}
...
...
malloc.c
View file @
e5028b9
...
...
@@ -45,9 +45,7 @@ int devzero_fd;
#endif
void
*
xmalloc
(
size_t
size
)
{
#ifdef _DEBUG
debug
(
20
,
"(%li)"
,
size
);
#endif
#ifdef PARANOID
size
++
;
// Just in case
#endif
...
...
@@ -64,9 +62,7 @@ void *xmalloc(size_t size) {
}
void
*
xcalloc
(
size_t
nmemb
,
size_t
size
)
{
#ifdef _DEBUG
debug
(
20
,
"(%li, %li)"
,
nmemb
,
size
);
#endif
#ifdef PARANOID
nmemb
++
;
// Just in case
size
++
;
// Just in case
...
...
@@ -82,9 +78,7 @@ void *xcalloc(size_t nmemb, size_t size) {
}
void
*
xrealloc
(
void
*
oldptr
,
size_t
size
)
{
#ifdef _DEBUG
debug
(
20
,
"(%p, %li)"
,
oldptr
,
size
);
#endif
#ifdef PARANOID
size
++
;
// Just in case
#endif
...
...
@@ -101,9 +95,7 @@ void *xrealloc(void *oldptr, size_t size) {
void
*
malloc_align
(
size_t
size
)
{
size_t
total_size
;
void
*
ret
=
NULL
;
# ifdef _DEBUG
debug
(
20
,
"(%li)"
,
size
);
# endif
# ifdef PARANOID
size
++
;
// Just in case
# endif
...
...
@@ -130,9 +122,7 @@ void *malloc_align(size_t size) {
void
*
calloc_align
(
size_t
nmemb
,
size_t
size
)
{
size_t
total_size
;
void
*
ret
;
# ifdef _DEBUG
debug
(
20
,
"(%li, %li)"
,
nmemb
,
size
);
# endif
# ifdef PARANOID
nmemb
++
;
// Just in case
size
++
;
// Just in case
...
...
Please
register
or
login
to post a comment