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
37e4f516
Commit
37e4f516
authored
8 years ago
by
Deomid Ryabkov
Committed by
Cesanta Bot
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MG_DISABLE_SOCKETPAIR -> MG_ENABLE_BROADCAST
PUBLISHED_FROM=81b6289a4b54043df557142f0de8cc66bc5190d4
parent
1dae0373
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
32 deletions
+41
-32
struct_mg_mgr.md
docs/c-api/net.h/struct_mg_mgr.md
+1
-1
disabling-flags.md
docs/overview/build-options/disabling-flags.md
+0
-1
enabling-flags.md
docs/overview/build-options/enabling-flags.md
+2
-1
mongoose.c
mongoose.c
+10
-11
mongoose.h
mongoose.h
+28
-18
No files found.
docs/c-api/net.h/struct_mg_mgr.md
View file @
37e4f516
...
...
@@ -8,7 +8,7 @@ signature: |
#if MG_ENABLE_HEXDUMP
const char *hexdump_file; /* Debug hexdump file path */
#endif
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
sock_t ctl[2]; /* Socketpair for mg_broadcast() */
#endif
void *user_data; /* User data */
...
...
This diff is collapsed.
Click to expand it.
docs/overview/build-options/disabling-flags.md
View file @
37e4f516
...
...
@@ -5,5 +5,4 @@ title: Disabling flags
-
`MG_DISABLE_HTTP_DIGEST_AUTH`
disable HTTP Digest (MD5) authorisation support
-
`MG_DISABLE_SHA1`
disable SHA1 support (used by WebSocket)
-
`MG_DISABLE_MD5`
disable MD5 support (used by HTTP auth)
-
`MG_DISABLE_SOCKETPAIR`
disable
`mg_broadcast()`
API
-
`MG_DISABLE_HTTP_KEEP_ALIVE`
useful for embedded systems to save resources
This diff is collapsed.
Click to expand it.
docs/overview/build-options/enabling-flags.md
View file @
37e4f516
...
...
@@ -3,7 +3,7 @@ title: Enabling flags
---
-
`MG_ENABLE_SSL`
Enable
[
SSL/TLS support
](
https://docs.cesanta.com/mongoose/master/#/http/ssl.md/
)
(
OpenSSL
API)
-
`MG_ENABLE_IPV6`
Enable IP
V
6 support
-
`MG_ENABLE_IPV6`
Enable IP
v
6 support
-
`MG_ENABLE_MQTT`
enable
[
MQTT client
](
https://docs.cesanta.com/mongoose/master/#/mqtt/client_example.md/
)
-
`MG_ENABLE_MQTT_BROKER`
enable
[
MQTT broker
](
https://docs.cesanta.com/mongoose/master/#/mqtt/server_example.md/
)
-
`MG_ENABLE_DNS_SERVER`
enable DNS server
...
...
@@ -14,5 +14,6 @@ title: Enabling flags
-
`MG_ENABLE_HTTP_SSI_EXEC`
Enable SSI
`exec`
operator
-
`MG_ENABLE_HTTP_WEBDAV`
enable WebDAV extensions to HTTP
-
`MG_ENABLE_HTTP_WEBSOCKET`
enable WebSocket extension to HTTP (on by default, =0 to disable)
-
`MG_ENABLE_BROADCAST`
enable
`mg_broadcast()`
API
-
`MG_ENABLE_GETADDRINFO`
enable
`getaddrinfo()`
in
`mg_resolve2()`
-
`MG_ENABLE_THREADS`
enable
`mg_start_thread()`
API
This diff is collapsed.
Click to expand it.
mongoose.c
View file @
37e4f516
...
...
@@ -45,7 +45,6 @@
#ifdef PICOTCP
#define NO_LIBC
#define MG_DISABLE_SOCKETPAIR
#define MG_DISABLE_PFS
#endif
...
...
@@ -1864,7 +1863,7 @@ void mg_close_conn(struct mg_connection *conn) {
void
mg_mgr_init
(
struct
mg_mgr
*
m
,
void
*
user_data
)
{
memset
(
m
,
0
,
sizeof
(
*
m
));
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
m
->
ctl
[
0
]
=
m
->
ctl
[
1
]
=
INVALID_SOCKET
;
#endif
m
->
user_data
=
user_data
;
...
...
@@ -1929,7 +1928,7 @@ void mg_mgr_free(struct mg_mgr *m) {
/* Do one last poll, see https://github.com/cesanta/mongoose/issues/286 */
mg_mgr_poll
(
m
,
0
);
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
if
(
m
->
ctl
[
0
]
!=
INVALID_SOCKET
)
closesocket
(
m
->
ctl
[
0
]);
if
(
m
->
ctl
[
1
]
!=
INVALID_SOCKET
)
closesocket
(
m
->
ctl
[
1
]);
m
->
ctl
[
0
]
=
m
->
ctl
[
1
]
=
INVALID_SOCKET
;
...
...
@@ -2688,7 +2687,7 @@ struct mg_connection *mg_next(struct mg_mgr *s, struct mg_connection *conn) {
return
conn
==
NULL
?
s
->
active_connections
:
conn
->
next
;
}
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
void
mg_broadcast
(
struct
mg_mgr
*
mgr
,
mg_event_handler_t
cb
,
void
*
data
,
size_t
len
)
{
struct
ctl_msg
ctl_msg
;
...
...
@@ -2712,7 +2711,7 @@ void mg_broadcast(struct mg_mgr *mgr, mg_event_handler_t cb, void *data,
(
void
)
dummy
;
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 */
}
}
#endif
/* MG_
DISABLE_SOCKETPAIR
*/
#endif
/* MG_
ENABLE_BROADCAST
*/
static
int
isbyte
(
int
n
)
{
return
n
>=
0
&&
n
<=
255
;
...
...
@@ -3263,7 +3262,7 @@ void mg_mgr_handle_conn(struct mg_connection *nc, int fd_flags, double now) {
(
int
)
nc
->
recv_mbuf
.
len
,
(
int
)
nc
->
send_mbuf
.
len
));
}
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
static
void
mg_mgr_handle_ctl_sock
(
struct
mg_mgr
*
mgr
)
{
struct
ctl_msg
ctl_msg
;
int
len
=
...
...
@@ -3291,7 +3290,7 @@ void mg_sock_set(struct mg_connection *nc, sock_t sock) {
void
mg_ev_mgr_init
(
struct
mg_mgr
*
mgr
)
{
(
void
)
mgr
;
DBG
((
"%p using select()"
,
mgr
));
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
do
{
mg_socketpair
(
mgr
->
ctl
,
SOCK_DGRAM
);
}
while
(
mgr
->
ctl
[
0
]
==
INVALID_SOCKET
);
...
...
@@ -3338,7 +3337,7 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
FD_ZERO
(
&
read_set
);
FD_ZERO
(
&
write_set
);
FD_ZERO
(
&
err_set
);
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
mg_add_to_set
(
mgr
->
ctl
[
1
],
&
read_set
,
&
max_fd
);
#endif
...
...
@@ -3408,7 +3407,7 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
DBG
((
"select @ %ld num_ev=%d of %d, timeout=%d"
,
(
long
)
now
,
num_ev
,
num_fds
,
timeout_ms
));
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
if
(
num_ev
>
0
&&
mgr
->
ctl
[
1
]
!=
INVALID_SOCKET
&&
FD_ISSET
(
mgr
->
ctl
[
1
],
&
read_set
))
{
mg_mgr_handle_ctl_sock
(
mgr
);
...
...
@@ -3446,7 +3445,7 @@ time_t mg_mgr_poll(struct mg_mgr *mgr, int timeout_ms) {
return
(
time_t
)
now
;
}
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
int
mg_socketpair
(
sock_t
sp
[
2
],
int
sock_type
)
{
union
socket_address
sa
;
sock_t
sock
;
...
...
@@ -3488,7 +3487,7 @@ int mg_socketpair(sock_t sp[2], int sock_type) {
return
ret
;
}
#endif
/* MG_
DISABLE_SOCKETPAIR
*/
#endif
/* MG_
ENABLE_BROADCAST
*/
static
void
mg_sock_get_addr
(
sock_t
sock
,
int
remote
,
union
socket_address
*
sa
)
{
...
...
This diff is collapsed.
Click to expand it.
mongoose.h
View file @
37e4f516
...
...
@@ -249,6 +249,10 @@ typedef struct _stati64 cs_stat_t;
#define CS_ENABLE_STDIO 1
#endif
#ifndef MG_ENABLE_BROADCAST
#define MG_ENABLE_BROADCAST 1
#endif
#ifndef MG_ENABLE_DIRECTORY_LISTING
#define MG_ENABLE_DIRECTORY_LISTING 1
#endif
...
...
@@ -257,6 +261,10 @@ typedef struct _stati64 cs_stat_t;
#define MG_ENABLE_FILESYSTEM 1
#endif
#ifndef MG_ENABLE_HTTP_CGI
#define MG_ENABLE_HTTP_CGI 1
#endif
#endif
/* CS_PLATFORM == CS_P_WINDOWS */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_WINDOWS_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -363,6 +371,10 @@ typedef struct stat cs_stat_t;
#define CS_ENABLE_STDIO 1
#endif
#ifndef MG_ENABLE_BROADCAST
#define MG_ENABLE_BROADCAST 1
#endif
#ifndef MG_ENABLE_DIRECTORY_LISTING
#define MG_ENABLE_DIRECTORY_LISTING 1
#endif
...
...
@@ -371,6 +383,10 @@ typedef struct stat cs_stat_t;
#define MG_ENABLE_FILESYSTEM 1
#endif
#ifndef MG_ENABLE_HTTP_CGI
#define MG_ENABLE_HTTP_CGI 1
#endif
#endif
/* CS_PLATFORM == CS_P_UNIX */
#endif
/* CS_COMMON_PLATFORMS_PLATFORM_UNIX_H_ */
#ifdef MG_MODULE_LINES
...
...
@@ -462,7 +478,6 @@ void mg_lwip_set_keepalive_params(struct mg_connection *nc, int idle,
#include <time.h>
#define MG_SOCKET_SIMPLELINK 1
#define MG_DISABLE_SOCKETPAIR 1
#define MG_DISABLE_SYNC_RESOLVER 1
/*
...
...
@@ -517,7 +532,6 @@ int inet_pton(int af, const char *src, void *dst);
#endif
#define MG_SOCKET_SIMPLELINK 1
#define MG_DISABLE_SOCKETPAIR 1
#define MG_DISABLE_SYNC_RESOLVER 1
/* Only SPIFFS supports directories, SLFS does not. */
...
...
@@ -653,7 +667,6 @@ struct dirent *readdir(DIR *dir);
#endif
#define MG_SOCKET_SIMPLELINK 1
#define MG_DISABLE_SOCKETPAIR 1
#define MG_DISABLE_SYNC_RESOLVER 1
/* Amalgamated: #include "common/platforms/simplelink/cs_simplelink.h" */
...
...
@@ -1393,10 +1406,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_SOCKET_IF 0
#endif
#ifndef MG_DISABLE_SOCKETPAIR
#define MG_DISABLE_SOCKETPAIR 0
#endif
#ifndef MG_DISABLE_SYNC_RESOLVER
#define MG_DISABLE_SYNC_RESOLVER 0
#endif
...
...
@@ -1405,13 +1414,8 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_DISABLE_WS_RANDOM_MASK 0
#endif
#ifndef MG_ENABLE_HTTP
#define MG_ENABLE_HTTP 1
#endif
#ifndef MG_ENABLE_HTTP_CGI
#define MG_ENABLE_HTTP_CGI \
(CS_PLATFORM == CS_P_UNIX || CS_PLATFORM == CS_P_WINDOWS)
#ifndef MG_ENABLE_BROADCAST
#define MG_ENABLE_BROADCAST 0
#endif
#ifndef MG_ENABLE_COAP
...
...
@@ -1446,6 +1450,14 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#define MG_ENABLE_HEXDUMP CS_ENABLE_STDIO
#endif
#ifndef MG_ENABLE_HTTP
#define MG_ENABLE_HTTP 1
#endif
#ifndef MG_ENABLE_HTTP_CGI
#define MG_ENABLE_HTTP_CGI 0
#endif
#ifndef MG_ENABLE_HTTP_SSI
#define MG_ENABLE_HTTP_SSI MG_ENABLE_FILESYSTEM
#endif
...
...
@@ -1505,8 +1517,6 @@ const char *c_strnstr(const char *s, const char *find, size_t slen);
#ifdef MG_NO_BSD_SOCKETS
#undef MG_DISABLE_SYNC_RESOLVER
#define MG_DISABLE_SYNC_RESOLVER 1
#undef MG_DISABLE_SOCKETPAIR
#define MG_DISABLE_SOCKETPAIR 1
#endif
/* MG_NO_BSD_SOCKETS */
/* MQTT broker requires MQTT */
...
...
@@ -1617,7 +1627,7 @@ struct mg_mgr {
#if MG_ENABLE_HEXDUMP
const
char
*
hexdump_file
;
/* Debug hexdump file path */
#endif
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
sock_t
ctl
[
2
];
/* Socketpair for mg_broadcast() */
#endif
void
*
user_data
;
/* User data */
...
...
@@ -1723,7 +1733,7 @@ void mg_mgr_free(struct mg_mgr *);
*/
time_t
mg_mgr_poll
(
struct
mg_mgr
*
,
int
milli
);
#if
!MG_DISABLE_SOCKETPAIR
#if
MG_ENABLE_BROADCAST
/*
* Passes a message of a given length to all connections.
*
...
...
This diff is collapsed.
Click to expand it.
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