Skip to content

Commit

Permalink
when login response has no error, ignore it
Browse files Browse the repository at this point in the history
according to 0.43.0's change

Signed-off-by: Dengfeng Liu <liudf0716@gmail.com>
  • Loading branch information
liudf0716 committed May 26, 2024
1 parent 68ffcb2 commit b88726a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,19 @@ login_request_marshal(char **msg)
JSON_MARSHAL_TYPE(j_login_req, "hostname", string, SAFE_JSON_STRING(lg->hostname));
JSON_MARSHAL_TYPE(j_login_req, "os", string, lg->os);
JSON_MARSHAL_TYPE(j_login_req, "arch", string, lg->arch);
JSON_MARSHAL_TYPE(j_login_req, "user", string, SAFE_JSON_STRING(lg->user));
if (lg->user)
JSON_MARSHAL_TYPE(j_login_req, "user", string, SAFE_JSON_STRING(lg->user));

JSON_MARSHAL_TYPE(j_login_req, "privilege_key", string, SAFE_JSON_STRING(lg->privilege_key));
if (sizeof(time_t) == 4) {
JSON_MARSHAL_TYPE(j_login_req, "timestamp", int, lg->timestamp);
} else {
JSON_MARSHAL_TYPE(j_login_req, "timestamp", int64, lg->timestamp);
}
JSON_MARSHAL_TYPE(j_login_req, "run_id", string, SAFE_JSON_STRING(lg->run_id));
if (lg->run_id)
JSON_MARSHAL_TYPE(j_login_req, "run_id", string, SAFE_JSON_STRING(lg->run_id));
JSON_MARSHAL_TYPE(j_login_req, "pool_count", int, lg->pool_count);
json_object_object_add(j_login_req, "metas", NULL);
//json_object_object_add(j_login_req, "metas", NULL);

const char *tmp = NULL;
tmp = json_object_to_json_string(j_login_req);
Expand Down Expand Up @@ -368,17 +370,11 @@ login_resp_unmarshal(const char *jres)
assert(lr->run_id);

struct json_object *l_error = NULL;
if (!json_object_object_get_ex(j_lg_res, "error", &l_error)) {
free(lr->version);
free(lr->run_id);
free(lr);
lr = NULL;
goto END_ERROR;
if (json_object_object_get_ex(j_lg_res, "error", &l_error)) {
lr->error = strdup(json_object_get_string(l_error));
assert(lr->error);
}

lr->error = strdup(json_object_get_string(l_error));
assert(lr->error);

END_ERROR:
json_object_put(j_lg_res);
return lr;
Expand Down

0 comments on commit b88726a

Please sign in to comment.