Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ubus-api-validator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IOPSYS
ubus-api-validator
Commits
ba1e6b6f
Commit
ba1e6b6f
authored
3 years ago
by
Vivek Dutta
Browse files
Options
Downloads
Patches
Plain Diff
Added customized timeout option for ubus call
parent
aadcbdd5
No related branches found
No related tags found
1 merge request
!3
Added customized timeout option for ubus call
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+6
-1
6 additions, 1 deletion
main.c
ubus_call.c
+8
-3
8 additions, 3 deletions
ubus_call.c
ubus_call.h
+2
-1
2 additions, 1 deletion
ubus_call.h
with
16 additions
and
5 deletions
main.c
+
6
−
1
View file @
ba1e6b6f
...
@@ -41,13 +41,14 @@ struct global_args_t {
...
@@ -41,13 +41,14 @@ struct global_args_t {
const
char
*
dir_path
;
const
char
*
dir_path
;
}
global_args
;
}
global_args
;
static
const
char
*
opt_string
=
"f:d:h"
;
static
const
char
*
opt_string
=
"f:d:
t:
h"
;
static
void
show_usage
(
char
*
application_name
)
{
static
void
show_usage
(
char
*
application_name
)
{
fprintf
(
stdout
,
fprintf
(
stdout
,
"
\n
Usage: %s: <options>
\n
"
"
\n
Usage: %s: <options>
\n
"
"Options:
\n
"
"Options:
\n
"
" -t Timeout for ubus call in seconds
\n
"
" -f json file with ubus objects
\n
"
" -f json file with ubus objects
\n
"
" -d directory with json files
\n
"
" -d directory with json files
\n
"
" -h help
\n\n
"
,
" -h help
\n\n
"
,
...
@@ -68,6 +69,10 @@ static void parse_command_line_args(int argc, char *argv[]) {
...
@@ -68,6 +69,10 @@ static void parse_command_line_args(int argc, char *argv[]) {
global_args
.
dir_path
=
optarg
;
global_args
.
dir_path
=
optarg
;
break
;
break
;
case
't'
:
set_ubus_timeout
(
atoi
(
optarg
));
break
;
case
'h'
:
case
'h'
:
show_usage
(
argv
[
0
]);
show_usage
(
argv
[
0
]);
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
...
...
This diff is collapsed.
Click to expand it.
ubus_call.c
+
8
−
3
View file @
ba1e6b6f
...
@@ -22,10 +22,15 @@
...
@@ -22,10 +22,15 @@
#include
"ubus_call.h"
#include
"ubus_call.h"
#include
<time.h>
#include
<time.h>
#define UBUS_DEFAULT_TIMEOUT 1500
#define UBUS_DEFAULT_POLL_10_SEC 10000
#define UBUS_DEFAULT_POLL_10_SEC 10000
#define UBUS_DEFAULT_TIMEOUT 1500
struct
ubus_context
*
ctx
;
struct
ubus_context
*
ctx
;
int
g_ubus_timeout
=
UBUS_DEFAULT_TIMEOUT
;
void
set_ubus_timeout
(
int
timeout
)
{
g_ubus_timeout
=
timeout
*
1000
;
}
int
ubus_init
(
void
)
{
int
ubus_init
(
void
)
{
...
@@ -99,7 +104,7 @@ struct ubus_result *ubus_call(const char *object, const char *method,
...
@@ -99,7 +104,7 @@ struct ubus_result *ubus_call(const char *object, const char *method,
rv
=
ubus_invoke
(
ctx
,
obj_id
,
method
,
buff
.
head
,
rv
=
ubus_invoke
(
ctx
,
obj_id
,
method
,
buff
.
head
,
(
ubus_data_handler_t
)
parse_ubus_cb
,
&
json_ubus_result
,
(
ubus_data_handler_t
)
parse_ubus_cb
,
&
json_ubus_result
,
UBUS_DEFAULT_TIMEOUT
);
g_ubus_timeout
);
res
=
calloc
(
1
,
sizeof
(
struct
ubus_result
));
res
=
calloc
(
1
,
sizeof
(
struct
ubus_result
));
if
(
!
res
)
if
(
!
res
)
...
@@ -112,4 +117,4 @@ out:
...
@@ -112,4 +117,4 @@ out:
blob_buf_free
(
&
buff
);
blob_buf_free
(
&
buff
);
return
res
;
return
res
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ubus_call.h
+
2
−
1
View file @
ba1e6b6f
...
@@ -13,8 +13,9 @@ struct ubus_result
...
@@ -13,8 +13,9 @@ struct ubus_result
};
};
int
ubus_init
(
void
);
int
ubus_init
(
void
);
void
set_ubus_timeout
(
int
timeout
);
struct
ubus_result
*
ubus_call
(
const
char
*
object
,
const
char
*
method
,
const
char
*
args
);
struct
ubus_result
*
ubus_call
(
const
char
*
object
,
const
char
*
method
,
const
char
*
args
);
#endif
/* UBUS_CALL_H */
#endif
/* UBUS_CALL_H */
\ No newline at end of file
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