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
2013-08-26 09:21:02 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4894590689d9ff27961e12a781821a7ab18801d4
48945906
1 parent
894b11da
fixed warning: ISO C99 doesn’t support unnamed structs/unions
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
28 deletions
cluster.c
cluster.h
cluster.c
View file @
4894590
...
...
@@ -281,7 +281,7 @@ int clustercmd_adler32_calc(clustercmd_t *clustercmd_p, clustercmdadler32_t *clu
uint32_t
adler32
;
uint32_t
size
=
clustercmd_p
->
h
.
data_len
;
char
*
ptr
=
clustercmd_p
->
data
_
p
;
char
*
ptr
=
clustercmd_p
->
data
.
p
;
#ifdef PARANOID
if
(
size
&
0x3
)
{
...
...
@@ -495,8 +495,8 @@ static inline int cluster_read(int sock, void *buf, size_t size, cluster_read_fl
static
inline
int
clustercmd_reject
(
clustercmd_t
*
clustercmd_p
,
uint8_t
reason
)
{
clustercmd_t
*
clustercmd_rej_p
=
CLUSTER_ALLOCA
(
clustercmd_rej_t
,
0
);
clustercmd_rej_p
->
h
.
dst_node_id
=
clustercmd_p
->
h
.
src_node_id
;
clustercmd_rej_p
->
data
_
rej
.
serial
=
clustercmd_p
->
h
.
serial
;
clustercmd_rej_p
->
data
_
rej
.
reason
=
reason
;
clustercmd_rej_p
->
data
.
rej
.
serial
=
clustercmd_p
->
h
.
serial
;
clustercmd_rej_p
->
data
.
rej
.
reason
=
reason
;
return
cluster_send
(
clustercmd_rej_p
);
}
...
...
@@ -700,7 +700,7 @@ static int cluster_recv(clustercmd_t **clustercmd_pp, unsigned int *timeout_p) {
}
// Reading the data
if
((
ret
=
cluster_read
(
sock_i
,
(
void
*
)
clustercmd_p
->
data
_
p
,
clustercmd_p
->
h
.
data_len
,
CLREAD_CONTINUE
)))
{
if
((
ret
=
cluster_read
(
sock_i
,
(
void
*
)
clustercmd_p
->
data
.
p
,
clustercmd_p
->
h
.
data_len
,
CLREAD_CONTINUE
)))
{
if
(
ret
==
-
1
)
return
0
;
printf_e
(
"Error: cluster_recv(): Got error from cluster_read(): %s (errno %i).
\n
"
,
...
...
@@ -776,7 +776,7 @@ static int cluster_recv(clustercmd_t **clustercmd_pp, unsigned int *timeout_p) {
static
int
cluster_recvproc_ack
(
clustercmd_t
*
clustercmd_p
)
{
uint32_t
cmd_serial_ack
=
clustercmd_p
->
data
_
ack
.
serial
;
uint32_t
cmd_serial_ack
=
clustercmd_p
->
data
.
ack
.
serial
;
clustercmdqueuedpacket_t
*
queuedpacket_p
=
(
clustercmdqueuedpacket_t
*
)
g_hash_table_lookup
(
nodeinfo_my
->
serial2queuedpacket_ht
,
GINT_TO_POINTER
(
cmd_serial_ack
));
...
...
@@ -786,11 +786,11 @@ static int cluster_recvproc_ack(clustercmd_t *clustercmd_p) {
uint8_t
node_id_from
=
clustercmd_p
->
h
.
src_node_id
;
if
(
!
queuedpacket_p
->
h
.
o
.
ack_from
[
node_id_from
])
{
queuedpacket_p
->
h
.
o
.
ack_count
++
;
queuedpacket_p
->
h
.
o
.
ack_from
[
node_id_from
]
++
;
if
(
!
queuedpacket_p
->
h
.
w
.
o
.
ack_from
[
node_id_from
])
{
queuedpacket_p
->
h
.
w
.
o
.
ack_count
++
;
queuedpacket_p
->
h
.
w
.
o
.
ack_from
[
node_id_from
]
++
;
if
(
queuedpacket_p
->
h
.
o
.
ack_count
==
node_count
-
1
)
if
(
queuedpacket_p
->
h
.
w
.
o
.
ack_count
==
node_count
-
1
)
clustercmd_window_del
(
&
window_o
,
queuedpacket_p
,
nodeinfo_my
->
serial2queuedpacket_ht
);
}
...
...
@@ -861,7 +861,7 @@ static int cluster_recvproc_setid(clustercmd_t *clustercmd_p) {
static
time_t
updatets
=
0
;
// Is this the most recent information? Skipping if not.
clustercmd_setiddata_t
*
data_setid_p
=
&
clustercmd_p
->
data
_
setid
;
clustercmd_setiddata_t
*
data_setid_p
=
&
clustercmd_p
->
data
.
setid
;
if
(
!
(
data_setid_p
->
updatets
>
updatets
))
return
0
;
...
...
@@ -1009,7 +1009,7 @@ int cluster_init(options_t *_options_p, indexes_t *_indexes_p) {
clustercmd_t
*
clustercmd_p
=
CLUSTER_ALLOCA
(
clustercmd_getmyid_t
,
options_p
->
cluster_nodename_len
);
clustercmd_p
->
h
.
data_len
=
options_p
->
cluster_nodename_len
;
memcpy
(
clustercmd_p
->
data
_
getmyid
.
node_name
,
options_p
->
cluster_nodename
,
clustercmd_p
->
h
.
data_len
+
1
);
memcpy
(
clustercmd_p
->
data
.
getmyid
.
node_name
,
options_p
->
cluster_nodename
,
clustercmd_p
->
h
.
data_len
+
1
);
clustercmd_p
->
h
.
cmd_id
=
CLUSTERCMDID_GETMYID
;
clustercmd_p
->
h
.
dst_node_id
=
NODEID_NOID
;
// broadcast
...
...
@@ -1049,12 +1049,12 @@ int cluster_init(options_t *_options_p, indexes_t *_indexes_p) {
// Sending registration information
node_status_change
(
node_id_my
,
NODESTATUS_SEEMSONLINE
);
{
clustercmd_t
*
clustercmd_p
=
CLUSTER_ALLOCA
(
clustercmd_reg
ister
_t
,
options_p
->
cluster_nodename_len
);
clustercmd_reg
ister_t
*
data_register_p
=
&
clustercmd_p
->
data_register
;
clustercmd_t
*
clustercmd_p
=
CLUSTER_ALLOCA
(
clustercmd_reg_t
,
options_p
->
cluster_nodename_len
);
clustercmd_reg
_t
*
data_reg_p
=
&
clustercmd_p
->
data
.
reg
;
memcpy
(
data_reg
ister
_p
->
node_name
,
options_p
->
cluster_nodename
,
options_p
->
cluster_nodename_len
+
1
);
memcpy
(
data_reg_p
->
node_name
,
options_p
->
cluster_nodename
,
options_p
->
cluster_nodename_len
+
1
);
clustercmd_p
->
h
.
cmd_id
=
CLUSTERCMDID_REG
ISTER
;
clustercmd_p
->
h
.
cmd_id
=
CLUSTERCMDID_REG
;
clustercmd_p
->
h
.
dst_node_id
=
NODEID_NOID
;
// broadcast
if
((
ret
=
cluster_send
(
clustercmd_p
)))
return
ret
;
...
...
cluster.h
View file @
4894590
...
...
@@ -118,7 +118,7 @@ typedef struct nodeinfo nodeinfo_t;
enum
clustercmd_id
{
CLUSTERCMDID_PING
=
0
,
CLUSTERCMDID_ACK
=
1
,
CLUSTERCMDID_REG
ISTER
=
2
,
CLUSTERCMDID_REG
=
2
,
CLUSTERCMDID_GETMYID
=
3
,
CLUSTERCMDID_SETID
=
4
,
COUNT_CLUSTERCMDID
...
...
@@ -136,10 +136,10 @@ struct clustercmd_setiddata {
};
typedef
struct
clustercmd_setiddata
clustercmd_setiddata_t
;
struct
clustercmd_reg
ister
{
struct
clustercmd_reg
{
char
node_name
[
1
];
};
typedef
struct
clustercmd_reg
ister
clustercmd_register
_t
;
typedef
struct
clustercmd_reg
clustercmd_reg
_t
;
struct
clustercmd_ack
{
uint32_t
serial
;
...
...
@@ -178,18 +178,19 @@ typedef struct clustercmdhdr clustercmdhdr_t;
struct
clustercmd
{
clustercmdhdr_t
h
;
union
{
char
data_
p
[
1
];
clustercmd_setiddata_t
data_
setid
;
clustercmd_reg
ister_t
data_register
;
clustercmd_ack_t
data_
ack
;
clustercmd_rej_t
data_
rej
;
clustercmd_getmyid_t
data_
getmyid
;
};
union
data
{
char
p
[
1
];
clustercmd_setiddata_t
setid
;
clustercmd_reg
_t
reg
;
clustercmd_ack_t
ack
;
clustercmd_rej_t
rej
;
clustercmd_getmyid_t
getmyid
;
}
data
;
};
typedef
struct
clustercmd
clustercmd_t
;
struct
clustercmdqueuedpackethdri
{
char
dummy
;
// anti-warning
};
typedef
struct
clustercmdqueuedpackethdri
clustercmdqueuedpackethdri_t
;
...
...
@@ -201,10 +202,10 @@ typedef struct clustercmdqueuedpackethdro clustercmdqueuedpackethdro_t;
struct
clustercmdqueuedpackethdr
{
unsigned
int
window_id
;
union
{
union
w
{
clustercmdqueuedpackethdri_t
i
;
clustercmdqueuedpackethdro_t
o
;
};
}
w
;
};
typedef
struct
clustercmdqueuedpackethdr
clustercmdqueuedpackethdr_t
;
...
...
Please
register
or
login
to post a comment