Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
abbd384d
Commit
abbd384d
authored
Jul 20, 2017
by
devsaurus
Browse files
first batch of review feedback
parent
070973e6
Changes
1
Show whitespace changes
Inline
Side-by-side
components/modules/net.c
View file @
abbd384d
...
...
@@ -212,7 +212,7 @@ static void net_dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg) {
static
bool
post_net_recv
(
lnet_userdata
*
ud
)
{
lnet_event
*
ev
=
(
lnet_event
*
)
malloc
(
sizeof
(
lnet_event
)
/*+ p->len*/
);
lnet_event
*
ev
=
(
lnet_event
*
)
malloc
(
sizeof
(
lnet_event
));
if
(
!
ev
)
return
false
;
...
...
@@ -258,10 +258,10 @@ static bool post_net_accept (lnet_userdata *ud) {
static
void
lnet_netconn_callback
(
struct
netconn
*
netconn
,
enum
netconn_evt
evt
,
u16_t
len
)
{
SYS_ARCH_DECL_PROTECT
(
lev
);
if
(
!
netconn
)
return
;
SYS_ARCH_DECL_PROTECT
(
lev
);
SYS_ARCH_PROTECT
(
lev
);
if
(
netconn
->
socket
<
0
)
{
if
(
evt
==
NETCONN_EVT_RCVPLUS
&&
len
>
0
)
{
...
...
@@ -287,7 +287,6 @@ static void lnet_netconn_callback(struct netconn *netconn, enum netconn_evt evt,
// connection established, trigger Lua callback
ud
->
client
.
connecting
=
false
;
post_net_connected
(
ud
);
}
else
if
(
len
>
0
)
{
// data sent, trigger Lua callback
post_net_sent
(
ud
);
...
...
@@ -320,13 +319,11 @@ static void lnet_netconn_callback(struct netconn *netconn, enum netconn_evt evt,
case
NETCONN_EVT_RCVPLUS
:
// new connection available from netconn_listen()
if
(
ud
->
netconn
&&
ud
->
self_ref
!=
LUA_NOREF
&&
ud
->
server
.
cb_accept_ref
!=
LUA_NOREF
)
{
post_net_accept
(
ud
);
}
break
;
// no error callback for server type
case
NETCONN_EVT_ERROR
:
post_net_err
(
ud
,
netconn_err
(
ud
->
netconn
));
break
;
...
...
@@ -1032,6 +1029,8 @@ static void lconnected_cb (lua_State *L, lnet_userdata *ud) {
}
static
void
laccept_cb
(
lua_State
*
L
,
lnet_userdata
*
ud
)
{
if
(
!
ud
||
!
ud
->
netconn
)
return
;
SYS_ARCH_DECL_PROTECT
(
lev
);
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
ud
->
server
.
cb_accept_ref
);
...
...
@@ -1068,7 +1067,7 @@ static void laccept_cb (lua_State *L, lnet_userdata *ud) {
}
static
void
lrecv_cb
(
lua_State
*
L
,
lnet_userdata
*
ud
)
{
if
(
!
ud
->
netconn
)
return
;
if
(
!
ud
||
!
ud
->
netconn
)
return
;
struct
netbuf
*
p
;
char
*
payload
;
...
...
@@ -1126,7 +1125,7 @@ static void lsent_cb (lua_State *L, lnet_userdata *ud) {
static
void
lerr_cb
(
lua_State
*
L
,
lnet_userdata
*
ud
,
err_t
err
)
{
if
(
!
ud
->
netconn
)
return
;
if
(
!
ud
||
!
ud
->
netconn
)
return
;
int
ref
;
if
(
err
!=
ERR_OK
&&
ud
->
client
.
cb_reconnect_ref
!=
LUA_NOREF
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment