Skip to content

Commit

Permalink
Fix a bug: the lepd crashes during the selftest function
Browse files Browse the repository at this point in the history
Signed-off-by: guanqiao <[email protected]>
  • Loading branch information
guanqiao committed Jun 14, 2019
1 parent e3fae33 commit c20c86d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/jsonrpc-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ static int selftest_procedure(struct jrpc_server *server) {
while (i--) {
pid = fork();
if (pid < 0)
printf("selftest: Fork failed!\n");
fprintf(stderr, "selftest: Fork failed!\n");
else if (pid == 0) {
jrpc_context ctx;
ctx.error_code = 0;
ctx.error_message = NULL;
cJSON *fake = cJSON_CreateObject();

printf("selftest:%s\n", server->procedures[i].name);
ctx.data = server->procedures[i].data;
server->procedures[i].function(&ctx, fake, fake);

Expand All @@ -102,7 +103,7 @@ static int selftest_procedure(struct jrpc_server *server) {
int stat_loc;

if (waitpid(pid, &stat_loc, 0) != pid)
printf("selftest: Wait pid(%d) error\n", pid);
fprintf(stderr, "selftest: Wait pid(%d) error\n", pid);

if (!stat_loc)
server->procedures[i].allow = 1;
Expand Down

0 comments on commit c20c86d

Please sign in to comment.