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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
libwebsockets
Commits
d607bb9b
Commit
d607bb9b
authored
9 years ago
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
clean more whitespace 2
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
e53f2ed5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/output.c
+19
-26
19 additions, 26 deletions
lib/output.c
lib/service.c
+22
-26
22 additions, 26 deletions
lib/service.c
with
41 additions
and
52 deletions
lib/output.c
+
19
−
26
View file @
d607bb9b
...
@@ -46,10 +46,8 @@ lws_0405_frame_mask_generate(struct lws *wsi)
...
@@ -46,10 +46,8 @@ lws_0405_frame_mask_generate(struct lws *wsi)
LWS_VISIBLE
void
lwsl_hexdump
(
void
*
vbuf
,
size_t
len
)
LWS_VISIBLE
void
lwsl_hexdump
(
void
*
vbuf
,
size_t
len
)
{
{
unsigned
int
n
;
unsigned
int
m
;
unsigned
int
start
;
unsigned
char
*
buf
=
(
unsigned
char
*
)
vbuf
;
unsigned
char
*
buf
=
(
unsigned
char
*
)
vbuf
;
unsigned
int
n
,
m
,
start
;
char
line
[
80
];
char
line
[
80
];
char
*
p
;
char
*
p
;
...
@@ -93,9 +91,8 @@ LWS_VISIBLE void lwsl_hexdump(void *vbuf, size_t len)
...
@@ -93,9 +91,8 @@ LWS_VISIBLE void lwsl_hexdump(void *vbuf, size_t len)
int
lws_issue_raw
(
struct
lws
*
wsi
,
unsigned
char
*
buf
,
size_t
len
)
int
lws_issue_raw
(
struct
lws
*
wsi
,
unsigned
char
*
buf
,
size_t
len
)
{
{
struct
lws_context
*
context
=
wsi
->
protocol
->
owning_server
;
struct
lws_context
*
context
=
wsi
->
protocol
->
owning_server
;
int
n
;
size_t
real_len
=
len
;
size_t
real_len
=
len
;
int
m
;
int
n
,
m
;
if
(
!
len
)
if
(
!
len
)
return
0
;
return
0
;
...
@@ -123,9 +120,7 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
...
@@ -123,9 +120,7 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
if
(
!
lws_socket_is_valid
(
wsi
->
sock
))
if
(
!
lws_socket_is_valid
(
wsi
->
sock
))
lwsl_warn
(
"** error invalid sock but expected to send
\n
"
);
lwsl_warn
(
"** error invalid sock but expected to send
\n
"
);
/*
/* nope, send it on the socket directly */
* nope, send it on the socket directly
*/
lws_latency_pre
(
context
,
wsi
);
lws_latency_pre
(
context
,
wsi
);
n
=
lws_ssl_capable_write
(
wsi
,
buf
,
len
);
n
=
lws_ssl_capable_write
(
wsi
,
buf
,
len
);
lws_latency
(
context
,
wsi
,
"send lws_issue_raw"
,
n
,
(
unsigned
int
)
n
==
len
);
lws_latency
(
context
,
wsi
,
"send lws_issue_raw"
,
n
,
(
unsigned
int
)
n
==
len
);
...
@@ -162,8 +157,7 @@ handle_truncated_send:
...
@@ -162,8 +157,7 @@ handle_truncated_send:
}
}
}
}
/* always callback on writeable */
/* always callback on writeable */
lws_callback_on_writable
(
lws_callback_on_writable
(
wsi
->
protocol
->
owning_server
,
wsi
);
wsi
->
protocol
->
owning_server
,
wsi
);
return
n
;
return
n
;
}
}
...
@@ -187,7 +181,7 @@ handle_truncated_send:
...
@@ -187,7 +181,7 @@ handle_truncated_send:
* first priority next time the socket is writable)
* first priority next time the socket is writable)
*/
*/
lwsl_info
(
"***** %x new partial sent %d from %d total
\n
"
,
lwsl_info
(
"***** %x new partial sent %d from %d total
\n
"
,
wsi
,
n
,
real_len
);
wsi
,
n
,
real_len
);
/*
/*
* - if we still have a suitable malloc lying around, use it
* - if we still have a suitable malloc lying around, use it
...
@@ -195,14 +189,14 @@ handle_truncated_send:
...
@@ -195,14 +189,14 @@ handle_truncated_send:
* - or, if no buffer, create it
* - or, if no buffer, create it
*/
*/
if
(
!
wsi
->
truncated_send_malloc
||
if
(
!
wsi
->
truncated_send_malloc
||
real_len
-
n
>
wsi
->
truncated_send_allocation
)
{
real_len
-
n
>
wsi
->
truncated_send_allocation
)
{
lws_free
(
wsi
->
truncated_send_malloc
);
lws_free
(
wsi
->
truncated_send_malloc
);
wsi
->
truncated_send_allocation
=
real_len
-
n
;
wsi
->
truncated_send_allocation
=
real_len
-
n
;
wsi
->
truncated_send_malloc
=
lws_malloc
(
real_len
-
n
);
wsi
->
truncated_send_malloc
=
lws_malloc
(
real_len
-
n
);
if
(
!
wsi
->
truncated_send_malloc
)
{
if
(
!
wsi
->
truncated_send_malloc
)
{
lwsl_err
(
"truncated send: unable to malloc %d
\n
"
,
lwsl_err
(
"truncated send: unable to malloc %d
\n
"
,
real_len
-
n
);
real_len
-
n
);
return
-
1
;
return
-
1
;
}
}
}
}
...
@@ -249,17 +243,15 @@ handle_truncated_send:
...
@@ -249,17 +243,15 @@ handle_truncated_send:
LWS_VISIBLE
int
lws_write
(
struct
lws
*
wsi
,
unsigned
char
*
buf
,
LWS_VISIBLE
int
lws_write
(
struct
lws
*
wsi
,
unsigned
char
*
buf
,
size_t
len
,
enum
lws_write_protocol
protocol
)
size_t
len
,
enum
lws_write_protocol
protocol
)
{
{
int
n
;
int
pre
=
0
;
int
post
=
0
;
int
masked7
=
wsi
->
mode
==
LWS_CONNMODE_WS_CLIENT
;
int
masked7
=
wsi
->
mode
==
LWS_CONNMODE_WS_CLIENT
;
unsigned
char
*
dropmask
=
NULL
;
unsigned
char
is_masked_bit
=
0
;
unsigned
char
is_masked_bit
=
0
;
size_t
orig_len
=
len
;
unsigned
char
*
dropmask
=
NULL
;
struct
lws_tokens
eff_buf
;
struct
lws_tokens
eff_buf
;
int
post
=
0
,
pre
=
0
,
n
;
size_t
orig_len
=
len
;
if
(
len
==
0
&&
protocol
!=
LWS_WRITE_CLOSE
&&
if
(
len
==
0
&&
protocol
!=
LWS_WRITE_CLOSE
&&
protocol
!=
LWS_WRITE_PING
&&
protocol
!=
LWS_WRITE_PONG
)
{
protocol
!=
LWS_WRITE_PING
&&
protocol
!=
LWS_WRITE_PONG
)
{
lwsl_warn
(
"zero length lws_write attempt
\n
"
);
lwsl_warn
(
"zero length lws_write attempt
\n
"
);
return
0
;
return
0
;
}
}
...
@@ -318,7 +310,6 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf,
...
@@ -318,7 +310,6 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf,
switch
(
wsi
->
ietf_spec_revision
)
{
switch
(
wsi
->
ietf_spec_revision
)
{
case
13
:
case
13
:
if
(
masked7
)
{
if
(
masked7
)
{
pre
+=
4
;
pre
+=
4
;
dropmask
=
&
buf
[
0
-
pre
];
dropmask
=
&
buf
[
0
-
pre
];
...
@@ -525,8 +516,8 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
...
@@ -525,8 +516,8 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
if
(
wsi
->
truncated_send_len
)
{
if
(
wsi
->
truncated_send_len
)
{
if
(
lws_issue_raw
(
wsi
,
wsi
->
truncated_send_malloc
+
if
(
lws_issue_raw
(
wsi
,
wsi
->
truncated_send_malloc
+
wsi
->
truncated_send_offset
,
wsi
->
truncated_send_offset
,
wsi
->
truncated_send_len
)
<
0
)
{
wsi
->
truncated_send_len
)
<
0
)
{
lwsl_info
(
"closing from lws_serve_http_file_fragment
\n
"
);
lwsl_info
(
"closing from lws_serve_http_file_fragment
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -537,14 +528,16 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
...
@@ -537,14 +528,16 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
goto
all_sent
;
goto
all_sent
;
compatible_file_read
(
n
,
wsi
->
u
.
http
.
fd
,
context
->
service_buffer
,
compatible_file_read
(
n
,
wsi
->
u
.
http
.
fd
,
context
->
service_buffer
,
sizeof
(
context
->
service_buffer
));
sizeof
(
context
->
service_buffer
));
if
(
n
<
0
)
if
(
n
<
0
)
return
-
1
;
/* caller will close */
return
-
1
;
/* caller will close */
if
(
n
)
{
if
(
n
)
{
lws_set_timeout
(
wsi
,
PENDING_TIMEOUT_HTTP_CONTENT
,
AWAITING_TIMEOUT
);
lws_set_timeout
(
wsi
,
PENDING_TIMEOUT_HTTP_CONTENT
,
AWAITING_TIMEOUT
);
wsi
->
u
.
http
.
filepos
+=
n
;
wsi
->
u
.
http
.
filepos
+=
n
;
m
=
lws_write
(
wsi
,
context
->
service_buffer
,
n
,
m
=
lws_write
(
wsi
,
context
->
service_buffer
,
n
,
wsi
->
u
.
http
.
filepos
==
wsi
->
u
.
http
.
filelen
?
LWS_WRITE_HTTP_FINAL
:
LWS_WRITE_HTTP
);
wsi
->
u
.
http
.
filepos
==
wsi
->
u
.
http
.
filelen
?
LWS_WRITE_HTTP_FINAL
:
LWS_WRITE_HTTP
);
if
(
m
<
0
)
if
(
m
<
0
)
return
-
1
;
return
-
1
;
...
@@ -555,7 +548,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
...
@@ -555,7 +548,7 @@ LWS_VISIBLE int lws_serve_http_file_fragment(struct lws_context *context,
}
}
all_sent:
all_sent:
if
(
!
wsi
->
truncated_send_len
&&
if
(
!
wsi
->
truncated_send_len
&&
wsi
->
u
.
http
.
filepos
==
wsi
->
u
.
http
.
filelen
)
{
wsi
->
u
.
http
.
filepos
==
wsi
->
u
.
http
.
filelen
)
{
wsi
->
state
=
WSI_STATE_HTTP
;
wsi
->
state
=
WSI_STATE_HTTP
;
/* we might be in keepalive, so close it off here */
/* we might be in keepalive, so close it off here */
...
...
This diff is collapsed.
Click to expand it.
lib/service.c
+
22
−
26
View file @
d607bb9b
...
@@ -39,22 +39,20 @@ lws_calllback_as_writeable(struct lws_context *context, struct lws *wsi)
...
@@ -39,22 +39,20 @@ lws_calllback_as_writeable(struct lws_context *context, struct lws *wsi)
}
}
lwsl_info
(
"%s: %p (user=%p)
\n
"
,
__func__
,
wsi
,
wsi
->
user_space
);
lwsl_info
(
"%s: %p (user=%p)
\n
"
,
__func__
,
wsi
,
wsi
->
user_space
);
return
user_callback_handle_rxflow
(
wsi
->
protocol
->
callback
,
context
,
return
user_callback_handle_rxflow
(
wsi
->
protocol
->
callback
,
context
,
wsi
,
(
enum
lws_callback_reasons
)
n
,
wsi
,
(
enum
lws_callback_reasons
)
n
,
wsi
->
user_space
,
NULL
,
0
);
wsi
->
user_space
,
NULL
,
0
);
}
}
int
int
lws_handle_POLLOUT_event
(
struct
lws_context
*
context
,
struct
lws
*
wsi
,
lws_handle_POLLOUT_event
(
struct
lws_context
*
context
,
struct
lws
*
wsi
,
struct
lws_pollfd
*
pollfd
)
struct
lws_pollfd
*
pollfd
)
{
{
int
n
;
int
write_type
=
LWS_WRITE_PONG
;
struct
lws_tokens
eff_buf
;
struct
lws_tokens
eff_buf
;
#ifdef LWS_USE_HTTP2
#ifdef LWS_USE_HTTP2
struct
lws
*
wsi2
;
struct
lws
*
wsi2
;
#endif
#endif
int
ret
;
int
ret
,
m
,
n
;
int
m
;
int
write_type
=
LWS_WRITE_PONG
;
/* pending truncated sends have uber priority */
/* pending truncated sends have uber priority */
...
@@ -100,11 +98,9 @@ lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
...
@@ -100,11 +98,9 @@ lws_handle_POLLOUT_event(struct lws_context *context, struct lws *wsi,
if
(
wsi
->
u
.
ws
.
payload_is_close
)
if
(
wsi
->
u
.
ws
.
payload_is_close
)
write_type
=
LWS_WRITE_CLOSE
;
write_type
=
LWS_WRITE_CLOSE
;
n
=
lws_write
(
wsi
,
n
=
lws_write
(
wsi
,
&
wsi
->
u
.
ws
.
ping_payload_buf
[
&
wsi
->
u
.
ws
.
ping_payload_buf
[
LWS_SEND_BUFFER_PRE_PADDING
],
LWS_SEND_BUFFER_PRE_PADDING
],
wsi
->
u
.
ws
.
ping_payload_len
,
wsi
->
u
.
ws
.
ping_payload_len
,
write_type
);
write_type
);
if
(
n
<
0
)
if
(
n
<
0
)
return
-
1
;
return
-
1
;
...
@@ -361,19 +357,19 @@ int lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len)
...
@@ -361,19 +357,19 @@ int lws_rxflow_cache(struct lws *wsi, unsigned char *buf, int n, int len)
LWS_VISIBLE
int
LWS_VISIBLE
int
lws_service_fd
(
struct
lws_context
*
context
,
struct
lws_pollfd
*
pollfd
)
lws_service_fd
(
struct
lws_context
*
context
,
struct
lws_pollfd
*
pollfd
)
{
{
struct
lws
*
wsi
;
int
n
,
m
;
lws_sockfd_type
mfd
;
#if LWS_POSIX
#if LWS_POSIX
int
listen_socket_fds_index
=
0
;
int
listen_socket_fds_index
=
0
;
#endif
#endif
time_t
now
;
int
timed_out
=
0
;
lws_sockfd_type
our_fd
=
0
;
lws_sockfd_type
our_fd
=
0
;
char
draining_flow
=
0
;
int
more
;
struct
lws_tokens
eff_buf
;
struct
lws_tokens
eff_buf
;
unsigned
int
pending
=
0
;
unsigned
int
pending
=
0
;
char
draining_flow
=
0
;
lws_sockfd_type
mfd
;
int
timed_out
=
0
;
struct
lws
*
wsi
;
time_t
now
;
int
n
,
m
;
int
more
;
#if LWS_POSIX
#if LWS_POSIX
if
(
context
->
listen_service_fd
)
if
(
context
->
listen_service_fd
)
...
@@ -407,11 +403,10 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
...
@@ -407,11 +403,10 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
if
(
lws_service_timeout_check
(
context
,
wsi
,
now
))
if
(
lws_service_timeout_check
(
context
,
wsi
,
now
))
/* he did time out... */
/* he did time out... */
if
(
mfd
==
our_fd
)
{
if
(
mfd
==
our_fd
)
/* it was the guy we came to service! */
/* it was the guy we came to service! */
timed_out
=
1
;
timed_out
=
1
;
/* he's gone, no need to mark as handled */
/* he's gone, no need to mark as handled */
}
}
}
}
}
...
@@ -420,12 +415,12 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
...
@@ -420,12 +415,12 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
return
0
;
return
0
;
/* just here for timeout management? */
/* just here for timeout management? */
if
(
pollfd
==
NULL
)
if
(
!
pollfd
)
return
0
;
return
0
;
/* no, here to service a socket descriptor */
/* no, here to service a socket descriptor */
wsi
=
wsi_from_fd
(
context
,
pollfd
->
fd
);
wsi
=
wsi_from_fd
(
context
,
pollfd
->
fd
);
if
(
wsi
==
NULL
)
if
(
!
wsi
)
/* not lws connection ... leave revents alone and return */
/* not lws connection ... leave revents alone and return */
return
0
;
return
0
;
...
@@ -459,7 +454,8 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
...
@@ -459,7 +454,8 @@ lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
* even with extpoll, we prepared this
* even with extpoll, we prepared this
* internal fds for listen
* internal fds for listen
*/
*/
n
=
lws_poll_listen_fd
(
&
context
->
fds
[
listen_socket_fds_index
]);
n
=
lws_poll_listen_fd
(
&
context
->
fds
[
listen_socket_fds_index
]);
if
(
n
>
0
)
{
/* there's a conn waiting for us */
if
(
n
>
0
)
{
/* there's a conn waiting for us */
lws_service_fd
(
context
,
lws_service_fd
(
context
,
&
context
->
&
context
->
...
@@ -572,7 +568,6 @@ read:
...
@@ -572,7 +568,6 @@ read:
drain:
drain:
do
{
do
{
more
=
0
;
more
=
0
;
m
=
lws_ext_callback_for_each_active
(
wsi
,
m
=
lws_ext_callback_for_each_active
(
wsi
,
...
@@ -602,8 +597,8 @@ drain:
...
@@ -602,8 +597,8 @@ drain:
pending
=
lws_ssl_pending
(
wsi
);
pending
=
lws_ssl_pending
(
wsi
);
if
(
pending
)
{
if
(
pending
)
{
handle_pending:
handle_pending:
pending
=
pending
>
sizeof
(
context
->
service_buffer
)
?
pending
=
pending
>
sizeof
(
context
->
service_buffer
)
?
sizeof
(
context
->
service_buffer
)
:
pending
;
sizeof
(
context
->
service_buffer
)
:
pending
;
goto
read
;
goto
read
;
}
}
...
@@ -615,7 +610,8 @@ handle_pending:
...
@@ -615,7 +610,8 @@ handle_pending:
#ifdef LWS_NO_SERVER
#ifdef LWS_NO_SERVER
n
=
n
=
#endif
#endif
_lws_rx_flow_control
(
wsi
);
/* n ignored, needed for NO_SERVER case */
_lws_rx_flow_control
(
wsi
);
/* n ignored, needed for NO_SERVER case */
}
}
break
;
break
;
...
...
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