Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libwebsockets
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
Fork
libwebsockets
Commits
38a1cbb4
Commit
38a1cbb4
authored
Feb 27, 2016
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
libuv create 1Hz background timeout check
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
f57a2b5a
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/context.c
+2
-0
2 additions, 0 deletions
lib/context.c
lib/libuv.c
+14
-0
14 additions, 0 deletions
lib/libuv.c
lib/private-libwebsockets.h
+3
-0
3 additions, 0 deletions
lib/private-libwebsockets.h
test-server/test-server-libuv.c
+3
-3
3 additions, 3 deletions
test-server/test-server-libuv.c
with
22 additions
and
3 deletions
lib/context.c
+
2
−
0
View file @
38a1cbb4
...
@@ -162,6 +162,8 @@ lws_create_context(struct lws_context_creation_info *info)
...
@@ -162,6 +162,8 @@ lws_create_context(struct lws_context_creation_info *info)
return
NULL
;
return
NULL
;
}
}
context
->
pt
[
n
].
context
=
context
;
context
->
pt
[
n
].
tid
=
n
;
context
->
pt
[
n
].
http_header_data
=
lws_malloc
(
context
->
max_http_header_data
*
context
->
pt
[
n
].
http_header_data
=
lws_malloc
(
context
->
max_http_header_data
*
context
->
max_http_header_pool
);
context
->
max_http_header_pool
);
if
(
!
context
->
pt
[
n
].
http_header_data
)
if
(
!
context
->
pt
[
n
].
http_header_data
)
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/libuv.c
+
14
−
0
View file @
38a1cbb4
...
@@ -74,6 +74,17 @@ lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
...
@@ -74,6 +74,17 @@ lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint,
return
0
;
return
0
;
}
}
static
void
lws_uv_timeout_cb
(
uv_timer_t
*
timer
)
{
struct
lws_context_per_thread
*
pt
=
container_of
(
timer
,
struct
lws_context_per_thread
,
uv_timeout_watcher
);
lwsl_info
(
"%s
\n
"
,
__func__
);
/* do timeout check only */
lws_service_fd_tsi
(
pt
->
context
,
NULL
,
pt
->
tid
);
}
static
const
int
sigs
[]
=
{
SIGINT
,
SIGTERM
,
SIGSEGV
,
SIGFPE
};
static
const
int
sigs
[]
=
{
SIGINT
,
SIGTERM
,
SIGSEGV
,
SIGFPE
};
LWS_VISIBLE
int
LWS_VISIBLE
int
...
@@ -112,6 +123,9 @@ lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, uv_signal_cb cb,
...
@@ -112,6 +123,9 @@ lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, uv_signal_cb cb,
uv_poll_start
(
&
wsi
->
w_read
.
uv_watcher
,
UV_READABLE
,
lws_accept_cb
);
uv_poll_start
(
&
wsi
->
w_read
.
uv_watcher
,
UV_READABLE
,
lws_accept_cb
);
}
}
uv_timer_init
(
pt
->
io_loop_uv
,
&
pt
->
uv_timeout_watcher
);
uv_timer_start
(
&
pt
->
uv_timeout_watcher
,
lws_uv_timeout_cb
,
1000
,
1000
);
return
status
;
return
status
;
}
}
...
...
...
...
This diff is collapsed.
Click to expand it.
lib/private-libwebsockets.h
+
3
−
0
View file @
38a1cbb4
...
@@ -538,6 +538,7 @@ struct lws_context_per_thread {
...
@@ -538,6 +538,7 @@ struct lws_context_per_thread {
struct
lws
*
rx_draining_ext_list
;
struct
lws
*
rx_draining_ext_list
;
struct
lws
*
tx_draining_ext_list
;
struct
lws
*
tx_draining_ext_list
;
struct
lws
*
timeout_list
;
struct
lws
*
timeout_list
;
struct
lws_context
*
context
;
#ifdef LWS_WITH_CGI
#ifdef LWS_WITH_CGI
struct
lws_cgi
*
cgi_list
;
struct
lws_cgi
*
cgi_list
;
#endif
#endif
...
@@ -557,6 +558,7 @@ struct lws_context_per_thread {
...
@@ -557,6 +558,7 @@ struct lws_context_per_thread {
#if defined(LWS_USE_LIBUV)
#if defined(LWS_USE_LIBUV)
uv_loop_t
*
io_loop_uv
;
uv_loop_t
*
io_loop_uv
;
uv_signal_t
signals
[
8
];
uv_signal_t
signals
[
8
];
uv_timer_t
uv_timeout_watcher
;
#endif
#endif
#if defined(LWS_USE_LIBEV)
#if defined(LWS_USE_LIBEV)
struct
lws_io_watcher
w_accept
;
struct
lws_io_watcher
w_accept
;
...
@@ -582,6 +584,7 @@ struct lws_context_per_thread {
...
@@ -582,6 +584,7 @@ struct lws_context_per_thread {
unsigned
int
fds_count
;
unsigned
int
fds_count
;
short
ah_count_in_use
;
short
ah_count_in_use
;
unsigned
char
tid
;
};
};
/*
/*
...
...
...
...
This diff is collapsed.
Click to expand it.
test-server/test-server-libuv.c
+
3
−
3
View file @
38a1cbb4
...
@@ -122,9 +122,8 @@ void signal_cb(uv_signal_t *watcher, int revents)
...
@@ -122,9 +122,8 @@ void signal_cb(uv_signal_t *watcher, int revents)
}
}
static
void
static
void
uv_timeout_cb
(
uv_timer_t
*
w
)
uv_timeout_cb
_dumb_increment
(
uv_timer_t
*
w
)
{
{
lwsl_info
(
"%s
\n
"
,
__func__
);
lws_callback_on_writable_all_protocol
(
context
,
lws_callback_on_writable_all_protocol
(
context
,
&
protocols
[
PROTOCOL_DUMB_INCREMENT
]);
&
protocols
[
PROTOCOL_DUMB_INCREMENT
]);
}
}
...
@@ -273,6 +272,7 @@ int main(int argc, char **argv)
...
@@ -273,6 +272,7 @@ int main(int argc, char **argv)
info
.
gid
=
-
1
;
info
.
gid
=
-
1
;
info
.
uid
=
-
1
;
info
.
uid
=
-
1
;
info
.
max_http_header_pool
=
1
;
info
.
max_http_header_pool
=
1
;
info
.
timeout_secs
=
5
;
info
.
options
=
opts
|
LWS_SERVER_OPTION_LIBUV
;
info
.
options
=
opts
|
LWS_SERVER_OPTION_LIBUV
;
context
=
lws_create_context
(
&
info
);
context
=
lws_create_context
(
&
info
);
...
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
...
@@ -284,7 +284,7 @@ int main(int argc, char **argv)
lws_uv_initloop
(
context
,
NULL
,
signal_cb
,
0
);
lws_uv_initloop
(
context
,
NULL
,
signal_cb
,
0
);
uv_timer_init
(
lws_uv_getloop
(
context
,
0
),
&
timeout_watcher
);
uv_timer_init
(
lws_uv_getloop
(
context
,
0
),
&
timeout_watcher
);
uv_timer_start
(
&
timeout_watcher
,
uv_timeout_cb
,
50
,
50
);
uv_timer_start
(
&
timeout_watcher
,
uv_timeout_cb
_dumb_increment
,
50
,
50
);
lws_libuv_run
(
context
,
0
);
lws_libuv_run
(
context
,
0
);
...
...
...
...
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
sign in
to comment