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
6bb49c78
Commit
6bb49c78
authored
Apr 09, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated net skeleton code
parent
3a60c576
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
mongoose.c
mongoose.c
+14
-17
No files found.
mongoose.c
View file @
6bb49c78
...
@@ -151,14 +151,14 @@ union socket_address {
...
@@ -151,14 +151,14 @@ union socket_address {
// IO buffers interface
// IO buffers interface
struct
iobuf
{
struct
iobuf
{
char
*
buf
;
char
*
buf
;
in
t
len
;
size_
t
len
;
in
t
size
;
size_
t
size
;
};
};
void
iobuf_init
(
struct
iobuf
*
,
in
t
initial_size
);
void
iobuf_init
(
struct
iobuf
*
,
size_
t
initial_size
);
void
iobuf_free
(
struct
iobuf
*
);
void
iobuf_free
(
struct
iobuf
*
);
int
iobuf_append
(
struct
iobuf
*
,
const
void
*
data
,
in
t
data_size
);
size_t
iobuf_append
(
struct
iobuf
*
,
const
void
*
data
,
size_
t
data_size
);
void
iobuf_remove
(
struct
iobuf
*
,
in
t
data_size
);
void
iobuf_remove
(
struct
iobuf
*
,
size_
t
data_size
);
// Net skeleton interface
// Net skeleton interface
// Events. Meaning of event parameter (evp) is given in the comment.
// Events. Meaning of event parameter (evp) is given in the comment.
...
@@ -270,7 +270,7 @@ int ns_hexdump(const void *buf, int len, char *dst, int dst_len);
...
@@ -270,7 +270,7 @@ int ns_hexdump(const void *buf, int len, char *dst, int dst_len);
#define IOBUF_RESIZE_MULTIPLIER 2.0
#define IOBUF_RESIZE_MULTIPLIER 2.0
#endif
#endif
void
iobuf_init
(
struct
iobuf
*
iobuf
,
in
t
size
)
{
void
iobuf_init
(
struct
iobuf
*
iobuf
,
size_
t
size
)
{
iobuf
->
len
=
iobuf
->
size
=
0
;
iobuf
->
len
=
iobuf
->
size
=
0
;
iobuf
->
buf
=
NULL
;
iobuf
->
buf
=
NULL
;
...
@@ -286,24 +286,21 @@ void iobuf_free(struct iobuf *iobuf) {
...
@@ -286,24 +286,21 @@ void iobuf_free(struct iobuf *iobuf) {
}
}
}
}
int
iobuf_append
(
struct
iobuf
*
io
,
const
void
*
buf
,
int
len
)
{
size_t
iobuf_append
(
struct
iobuf
*
io
,
const
void
*
buf
,
size_t
len
)
{
static
const
double
mult
=
IOBUF_RESIZE_MULTIPLIER
;
char
*
p
=
NULL
;
char
*
p
=
NULL
;
int
new_len
=
0
;
size_t
new_len
=
io
->
len
+
len
,
new_size
=
new_len
*
IOBUF_RESIZE_MULTIPLIER
;
assert
(
io
->
len
>=
0
);
assert
(
io
->
len
<=
io
->
size
);
assert
(
io
->
len
<=
io
->
size
);
if
(
len
<=
0
)
{
if
(
len
<=
0
)
{
}
else
if
(
(
new_len
=
io
->
len
+
len
)
<
io
->
size
)
{
}
else
if
(
new_len
<
io
->
size
)
{
memcpy
(
io
->
buf
+
io
->
len
,
buf
,
len
);
memcpy
(
io
->
buf
+
io
->
len
,
buf
,
len
);
io
->
len
=
new_len
;
io
->
len
=
new_len
;
}
else
if
((
p
=
(
char
*
)
}
else
if
((
p
=
(
char
*
)
NS_REALLOC
(
io
->
buf
,
new_size
))
!=
NULL
)
{
NS_REALLOC
(
io
->
buf
,
(
int
)
(
new_len
*
mult
)))
!=
NULL
)
{
io
->
buf
=
p
;
io
->
buf
=
p
;
memcpy
(
io
->
buf
+
io
->
len
,
buf
,
len
);
memcpy
(
io
->
buf
+
io
->
len
,
buf
,
len
);
io
->
len
=
new_len
;
io
->
len
=
new_len
;
io
->
size
=
(
int
)
(
new_len
*
mult
)
;
io
->
size
=
new_size
;
}
else
{
}
else
{
len
=
0
;
len
=
0
;
}
}
...
@@ -311,8 +308,8 @@ int iobuf_append(struct iobuf *io, const void *buf, int len) {
...
@@ -311,8 +308,8 @@ int iobuf_append(struct iobuf *io, const void *buf, int len) {
return
len
;
return
len
;
}
}
void
iobuf_remove
(
struct
iobuf
*
io
,
in
t
n
)
{
void
iobuf_remove
(
struct
iobuf
*
io
,
size_
t
n
)
{
if
(
n
>
=
0
&&
n
<=
io
->
len
)
{
if
(
n
>
0
&&
n
<=
io
->
len
)
{
memmove
(
io
->
buf
,
io
->
buf
+
n
,
io
->
len
-
n
);
memmove
(
io
->
buf
,
io
->
buf
+
n
,
io
->
len
-
n
);
io
->
len
-=
n
;
io
->
len
-=
n
;
}
}
...
@@ -597,7 +594,7 @@ static struct ns_connection *accept_conn(struct ns_server *server) {
...
@@ -597,7 +594,7 @@ static struct ns_connection *accept_conn(struct ns_server *server) {
ns_add_conn
(
server
,
c
);
ns_add_conn
(
server
,
c
);
ns_call
(
c
,
NS_ACCEPT
,
&
sa
);
ns_call
(
c
,
NS_ACCEPT
,
&
sa
);
DBG
((
"%p %d %p %p
%d"
,
c
,
c
->
sock
,
c
->
ssl
,
server
->
ssl_ctx
,
c
->
flags
));
DBG
((
"%p %d %p %p
"
,
c
,
c
->
sock
,
c
->
ssl
,
server
->
ssl_ctx
));
}
}
return
c
;
return
c
;
...
...
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