Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
35a2b38b
Commit
35a2b38b
authored
2 months ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
tools/cnode: show value ID when put completes
parent
5237f0a3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/dhtcnode.c
+13
-4
13 additions, 4 deletions
tools/dhtcnode.c
with
13 additions
and
4 deletions
tools/dhtcnode.c
+
13
−
4
View file @
35a2b38b
...
...
@@ -23,6 +23,7 @@
#include
<unistd.h>
#include
<stdlib.h>
#include
<stdatomic.h>
#include
<inttypes.h>
#include
<getopt.h>
#include
<readline/readline.h>
...
...
@@ -38,6 +39,10 @@ struct listen_context {
dht_op_token
*
token
;
size_t
count
;
};
struct
put_context
{
dht_runner
*
runner
;
dht_value
*
value
;
};
bool
dht_value_callback
(
const
dht_value
*
value
,
bool
expired
,
void
*
user_data
)
{
...
...
@@ -67,8 +72,10 @@ void dht_get_done_callback(bool ok, void* user_data)
void
dht_put_done_callback
(
bool
ok
,
void
*
user_data
)
{
dht_runner
*
runner
=
(
dht_runner
*
)
user_data
;
printf
(
"Put completed: %s
\n
"
,
ok
?
"success !"
:
"failure :-("
);
struct
put_context
*
ctx
=
(
struct
put_context
*
)
user_data
;
printf
(
"Put completed (id: %"
PRIx64
"): %s
\n
"
,
dht_value_get_id
(
ctx
->
value
),
ok
?
"success !"
:
"failure :-("
);
dht_value_unref
(
ctx
->
value
);
free
(
ctx
);
}
void
dht_shutdown_callback
(
void
*
user_data
)
...
...
@@ -261,8 +268,10 @@ int main(int argc, char **argv)
else
if
(
!
strcmp
(
cmd
,
"p"
))
{
key
=
parse_key
(
arg
);
dht_value
*
val
=
dht_value_new_from_string
(
value
);
dht_runner_put
(
runner
,
&
key
,
val
,
dht_put_done_callback
,
runner
,
true
);
dht_value_unref
(
val
);
struct
put_context
*
ctx
=
malloc
(
sizeof
(
struct
put_context
));
ctx
->
runner
=
runner
;
ctx
->
value
=
val
;
dht_runner_put
(
runner
,
&
key
,
val
,
dht_put_done_callback
,
ctx
,
true
);
}
else
{
printf
(
"Unknown command: %s
\n
"
,
cmd
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment