Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
53b784b1
Commit
53b784b1
authored
Sep 19, 2014
by
Ake Hedman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connection_data -> user_data
parent
8e91e3a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
mongoose.c
mongoose.c
+17
-17
No files found.
mongoose.c
View file @
53b784b1
...
@@ -209,7 +209,7 @@ struct ns_connection {
...
@@ -209,7 +209,7 @@ struct ns_connection {
struct
iobuf
send_iobuf
;
struct
iobuf
send_iobuf
;
SSL
*
ssl
;
SSL
*
ssl
;
SSL_CTX
*
ssl_ctx
;
SSL_CTX
*
ssl_ctx
;
void
*
connection
_data
;
void
*
user
_data
;
time_t
last_io_time
;
time_t
last_io_time
;
unsigned
int
flags
;
unsigned
int
flags
;
...
@@ -462,7 +462,7 @@ static void hexdump(struct ns_connection *nc, const char *path,
...
@@ -462,7 +462,7 @@ static void hexdump(struct ns_connection *nc, const char *path,
ns_sock_to_str
(
nc
->
sock
,
src
,
sizeof
(
src
),
3
);
ns_sock_to_str
(
nc
->
sock
,
src
,
sizeof
(
src
),
3
);
ns_sock_to_str
(
nc
->
sock
,
dst
,
sizeof
(
dst
),
7
);
ns_sock_to_str
(
nc
->
sock
,
dst
,
sizeof
(
dst
),
7
);
fprintf
(
fp
,
"%lu %p %s %s %s %d
\n
"
,
(
unsigned
long
)
time
(
NULL
),
fprintf
(
fp
,
"%lu %p %s %s %s %d
\n
"
,
(
unsigned
long
)
time
(
NULL
),
nc
->
connection
_data
,
src
,
nc
->
user
_data
,
src
,
ev
==
NS_RECV
?
"<-"
:
ev
==
NS_SEND
?
"->"
:
ev
==
NS_RECV
?
"<-"
:
ev
==
NS_SEND
?
"->"
:
ev
==
NS_ACCEPT
?
"<A"
:
ev
==
NS_CONNECT
?
"C>"
:
"XX"
,
ev
==
NS_ACCEPT
?
"<A"
:
ev
==
NS_CONNECT
?
"C>"
:
"XX"
,
dst
,
num_bytes
);
dst
,
num_bytes
);
...
@@ -720,7 +720,7 @@ struct ns_connection *ns_bind(struct ns_mgr *srv, const char *str, void *data) {
...
@@ -720,7 +720,7 @@ struct ns_connection *ns_bind(struct ns_mgr *srv, const char *str, void *data) {
}
else
{
}
else
{
nc
->
sa
=
sa
;
nc
->
sa
=
sa
;
nc
->
flags
|=
NSF_LISTENING
;
nc
->
flags
|=
NSF_LISTENING
;
nc
->
connection
_data
=
data
;
nc
->
user
_data
=
data
;
if
(
proto
==
SOCK_DGRAM
)
{
if
(
proto
==
SOCK_DGRAM
)
{
nc
->
flags
|=
NSF_UDP
;
nc
->
flags
|=
NSF_UDP
;
...
@@ -1129,7 +1129,7 @@ struct ns_connection *ns_add_sock(struct ns_mgr *s, sock_t sock, void *p) {
...
@@ -1129,7 +1129,7 @@ struct ns_connection *ns_add_sock(struct ns_mgr *s, sock_t sock, void *p) {
ns_set_non_blocking_mode
(
sock
);
ns_set_non_blocking_mode
(
sock
);
ns_set_close_on_exec
(
sock
);
ns_set_close_on_exec
(
sock
);
conn
->
sock
=
sock
;
conn
->
sock
=
sock
;
conn
->
connection
_data
=
p
;
conn
->
user
_data
=
p
;
conn
->
mgr
=
s
;
conn
->
mgr
=
s
;
conn
->
last_io_time
=
time
(
NULL
);
conn
->
last_io_time
=
time
(
NULL
);
ns_add_conn
(
s
,
conn
);
ns_add_conn
(
s
,
conn
);
...
@@ -2209,7 +2209,7 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
...
@@ -2209,7 +2209,7 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
}
}
static
void
on_cgi_data
(
struct
ns_connection
*
nc
)
{
static
void
on_cgi_data
(
struct
ns_connection
*
nc
)
{
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
const
char
*
status
=
"500"
;
const
char
*
status
=
"500"
;
struct
mg_connection
c
;
struct
mg_connection
c
;
...
@@ -4629,7 +4629,7 @@ struct mg_connection *mg_connect(struct mg_server *server, const char *addr) {
...
@@ -4629,7 +4629,7 @@ struct mg_connection *mg_connect(struct mg_server *server, const char *addr) {
// Interlink two structs
// Interlink two structs
conn
->
ns_conn
=
nsconn
;
conn
->
ns_conn
=
nsconn
;
nsconn
->
connection
_data
=
conn
;
nsconn
->
user
_data
=
conn
;
conn
->
server
=
server
;
conn
->
server
=
server
;
conn
->
endpoint_type
=
EP_CLIENT
;
conn
->
endpoint_type
=
EP_CLIENT
;
...
@@ -4699,7 +4699,7 @@ static void close_local_endpoint(struct connection *conn) {
...
@@ -4699,7 +4699,7 @@ static void close_local_endpoint(struct connection *conn) {
if
(
conn
->
endpoint
.
nc
!=
NULL
)
{
if
(
conn
->
endpoint
.
nc
!=
NULL
)
{
DBG
((
"%p %p %p :-)"
,
conn
,
conn
->
ns_conn
,
conn
->
endpoint
.
nc
));
DBG
((
"%p %p %p :-)"
,
conn
,
conn
->
ns_conn
,
conn
->
endpoint
.
nc
));
conn
->
endpoint
.
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
conn
->
endpoint
.
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
conn
->
endpoint
.
nc
->
connection
_data
=
NULL
;
conn
->
endpoint
.
nc
->
user
_data
=
NULL
;
}
}
break
;
break
;
default:
break
;
default:
break
;
...
@@ -4784,8 +4784,8 @@ struct mg_connection *mg_next(struct mg_server *s, struct mg_connection *c) {
...
@@ -4784,8 +4784,8 @@ struct mg_connection *mg_next(struct mg_server *s, struct mg_connection *c) {
struct
connection
*
conn
=
MG_CONN_2_CONN
(
c
);
struct
connection
*
conn
=
MG_CONN_2_CONN
(
c
);
struct
ns_connection
*
nc
=
ns_next
(
&
s
->
ns_mgr
,
struct
ns_connection
*
nc
=
ns_next
(
&
s
->
ns_mgr
,
c
==
NULL
?
NULL
:
conn
->
ns_conn
);
c
==
NULL
?
NULL
:
conn
->
ns_conn
);
if
(
nc
!=
NULL
&&
nc
->
connection
_data
!=
NULL
)
{
if
(
nc
!=
NULL
&&
nc
->
user
_data
!=
NULL
)
{
return
&
((
struct
connection
*
)
nc
->
connection
_data
)
->
mg_conn
;
return
&
((
struct
connection
*
)
nc
->
user
_data
)
->
mg_conn
;
}
else
{
}
else
{
return
NULL
;
return
NULL
;
}
}
...
@@ -4976,7 +4976,7 @@ const char *mg_set_option(struct mg_server *server, const char *name,
...
@@ -4976,7 +4976,7 @@ const char *mg_set_option(struct mg_server *server, const char *name,
}
}
static
void
set_ips
(
struct
ns_connection
*
nc
,
int
is_rem
)
{
static
void
set_ips
(
struct
ns_connection
*
nc
,
int
is_rem
)
{
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
struct
mg_connection
*
c
=
&
conn
->
mg_conn
;
struct
mg_connection
*
c
=
&
conn
->
mg_conn
;
char
buf
[
100
];
char
buf
[
100
];
...
@@ -4997,7 +4997,7 @@ static void on_accept(struct ns_connection *nc, union socket_address *sa) {
...
@@ -4997,7 +4997,7 @@ static void on_accept(struct ns_connection *nc, union socket_address *sa) {
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
nc
->
flags
|=
NSF_CLOSE_IMMEDIATELY
;
}
else
{
}
else
{
// Circularly link two connection structures
// Circularly link two connection structures
nc
->
connection
_data
=
conn
;
nc
->
user
_data
=
conn
;
conn
->
ns_conn
=
nc
;
conn
->
ns_conn
=
nc
;
// Initialize the rest of connection attributes
// Initialize the rest of connection attributes
...
@@ -5021,13 +5021,13 @@ static void process_udp(struct ns_connection *nc) {
...
@@ -5021,13 +5021,13 @@ static void process_udp(struct ns_connection *nc) {
}
}
static
void
mg_ev_handler
(
struct
ns_connection
*
nc
,
enum
ns_event
ev
,
void
*
p
)
{
static
void
mg_ev_handler
(
struct
ns_connection
*
nc
,
enum
ns_event
ev
,
void
*
p
)
{
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
// Send NS event to the handler. Note that call_user won't send an event
// Send NS event to the handler. Note that call_user won't send an event
// if conn == NULL. Therefore, repeat this for NS_ACCEPT event as well.
// if conn == NULL. Therefore, repeat this for NS_ACCEPT event as well.
#ifdef MONGOOSE_SEND_NS_EVENTS
#ifdef MONGOOSE_SEND_NS_EVENTS
{
{
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
void
*
param
[
2
]
=
{
nc
,
p
};
void
*
param
[
2
]
=
{
nc
,
p
};
if
(
conn
!=
NULL
)
conn
->
mg_conn
.
callback_param
=
param
;
if
(
conn
!=
NULL
)
conn
->
mg_conn
.
callback_param
=
param
;
call_user
(
conn
,
(
enum
mg_event
)
ev
);
call_user
(
conn
,
(
enum
mg_event
)
ev
);
...
@@ -5039,7 +5039,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
...
@@ -5039,7 +5039,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
on_accept
(
nc
,
(
union
socket_address
*
)
p
);
on_accept
(
nc
,
(
union
socket_address
*
)
p
);
#ifdef MONGOOSE_SEND_NS_EVENTS
#ifdef MONGOOSE_SEND_NS_EVENTS
{
{
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
void
*
param
[
2
]
=
{
nc
,
p
};
void
*
param
[
2
]
=
{
nc
,
p
};
if
(
conn
!=
NULL
)
conn
->
mg_conn
.
callback_param
=
param
;
if
(
conn
!=
NULL
)
conn
->
mg_conn
.
callback_param
=
param
;
call_user
(
conn
,
(
enum
mg_event
)
ev
);
call_user
(
conn
,
(
enum
mg_event
)
ev
);
...
@@ -5048,7 +5048,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
...
@@ -5048,7 +5048,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
break
;
break
;
case
NS_CONNECT
:
case
NS_CONNECT
:
if
(
nc
->
connection
_data
!=
NULL
)
{
if
(
nc
->
user
_data
!=
NULL
)
{
set_ips
(
nc
,
1
);
set_ips
(
nc
,
1
);
set_ips
(
nc
,
0
);
set_ips
(
nc
,
0
);
}
}
...
@@ -5086,7 +5086,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
...
@@ -5086,7 +5086,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
break
;
break
;
case
NS_CLOSE
:
case
NS_CLOSE
:
nc
->
connection
_data
=
NULL
;
nc
->
user
_data
=
NULL
;
if
(
nc
->
flags
&
(
MG_CGI_CONN
|
MG_PROXY_CONN
))
{
if
(
nc
->
flags
&
(
MG_CGI_CONN
|
MG_PROXY_CONN
))
{
DBG
((
"%p %p closing cgi/proxy conn"
,
conn
,
nc
));
DBG
((
"%p %p closing cgi/proxy conn"
,
conn
,
nc
));
if
(
conn
&&
conn
->
ns_conn
)
{
if
(
conn
&&
conn
->
ns_conn
)
{
...
@@ -5146,7 +5146,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
...
@@ -5146,7 +5146,7 @@ static void mg_ev_handler(struct ns_connection *nc, enum ns_event ev, void *p) {
static
void
iter2
(
struct
ns_connection
*
nc
,
enum
ns_event
ev
,
void
*
param
)
{
static
void
iter2
(
struct
ns_connection
*
nc
,
enum
ns_event
ev
,
void
*
param
)
{
mg_handler_t
func
=
NULL
;
mg_handler_t
func
=
NULL
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
connection
_data
;
struct
connection
*
conn
=
(
struct
connection
*
)
nc
->
user
_data
;
const
char
*
msg
=
(
const
char
*
)
param
;
const
char
*
msg
=
(
const
char
*
)
param
;
int
n
;
int
n
;
(
void
)
ev
;
(
void
)
ev
;
...
...
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