Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
6a54704b
Commit
6a54704b
authored
Jun 11, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mg_set_option(): always set correct actual listening port
parent
8a2fbac4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
22 deletions
+4
-22
unit_test.c
examples/unit_test.c
+0
-16
mongoose.c
mongoose.c
+4
-6
No files found.
examples/unit_test.c
View file @
6a54704b
...
...
@@ -502,21 +502,6 @@ static const char *test_rewrites(void) {
return
NULL
;
}
static
const
char
*
test_mg_parse_url
(
void
)
{
unsigned
short
port
;
char
a
[
100
],
b
[
100
];
ASSERT
(
parse_url
(
""
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
0
);
ASSERT
(
parse_url
(
"ws://foo "
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
8
);
ASSERT
(
strcmp
(
a
,
"ws"
)
==
0
&&
strcmp
(
b
,
"foo"
)
==
0
&&
port
==
80
);
ASSERT
(
parse_url
(
"xx://y:123 "
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
10
);
ASSERT
(
strcmp
(
a
,
"xx"
)
==
0
&&
strcmp
(
b
,
"y"
)
==
0
&&
port
==
123
);
ASSERT
(
parse_url
(
" foo "
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
0
);
ASSERT
(
parse_url
(
" foo:44 "
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
0
);
ASSERT
(
parse_url
(
"foo:44 "
,
a
,
sizeof
(
a
),
b
,
sizeof
(
b
),
&
port
)
==
6
);
ASSERT
(
strcmp
(
a
,
""
)
==
0
&&
strcmp
(
b
,
"foo"
)
==
0
&&
port
==
44
);
return
NULL
;
}
static
const
char
*
run_all_tests
(
void
)
{
RUN_TEST
(
test_should_keep_alive
);
RUN_TEST
(
test_match_prefix
);
...
...
@@ -533,7 +518,6 @@ static const char *run_all_tests(void) {
RUN_TEST
(
test_mg_set_option
);
RUN_TEST
(
test_server
);
RUN_TEST
(
test_rewrites
);
RUN_TEST
(
test_mg_parse_url
);
return
NULL
;
}
...
...
mongoose.c
View file @
6a54704b
...
...
@@ -677,8 +677,8 @@ void ns_sock_to_str(sock_t sock, char *buf, size_t len, int flags) {
#endif
}
if
(
flags
&
2
)
{
snprintf
(
buf
+
strlen
(
buf
),
len
-
(
strlen
(
buf
)
+
1
),
"
:
%d"
,
(
int
)
ntohs
(
sa
.
sin
.
sin_port
));
snprintf
(
buf
+
strlen
(
buf
),
len
-
(
strlen
(
buf
)
+
1
),
"
%s
%d"
,
flags
&
1
?
":"
:
""
,
(
int
)
ntohs
(
sa
.
sin
.
sin_port
));
}
}
}
...
...
@@ -4732,13 +4732,11 @@ const char *mg_set_option(struct mg_server *server, const char *name,
if
(
port
<
0
)
{
error_msg
=
"Cannot bind to port"
;
}
else
{
if
(
!
strcmp
(
value
,
"0"
))
{
char
buf
[
10
];
mg_snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
port
);
char
buf
[
100
];
ns_sock_to_str
(
server
->
ns_server
.
listening_sock
,
buf
,
sizeof
(
buf
),
2
);
free
(
*
v
);
*
v
=
mg_strdup
(
buf
);
}
}
#ifndef _WIN32
}
else
if
(
ind
==
RUN_AS_USER
)
{
struct
passwd
*
pw
;
...
...
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