-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add warning if firewall blocks loopback (closes #2621)
- Loading branch information
1 parent
72c0f21
commit 596c3d6
Showing
2 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff --git a/src/mongoose.c b/src/mongoose.c | ||
index c9c40863..55bd01e1 100644 | ||
--- a/src/mongoose.c | ||
+++ b/src/mongoose.c | ||
@@ -3459,14 +3459,17 @@ void mg_broadcast(struct mg_mgr *mgr, mg_event_handler_t cb, void *data, | ||
*/ | ||
if (mgr->ctl[0] != INVALID_SOCKET && data != NULL && | ||
len < sizeof(ctl_msg.message)) { | ||
- size_t dummy; | ||
+ size_t ret; | ||
|
||
ctl_msg.callback = cb; | ||
memcpy(ctl_msg.message, data, len); | ||
- dummy = MG_SEND_FUNC(mgr->ctl[0], (char *) &ctl_msg, | ||
+ ret = MG_SEND_FUNC(mgr->ctl[0], (char *) &ctl_msg, | ||
offsetof(struct ctl_msg, message) + len, 0); | ||
- dummy = MG_RECV_FUNC(mgr->ctl[0], (char *) &len, 1, 0); | ||
- (void) dummy; /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 */ | ||
+ if (ret < 0) | ||
+ perror("mg_broadcast() send failed, check UDP loopback device"); | ||
+ ret = MG_RECV_FUNC(mgr->ctl[0], (char *) &len, 1, 0); | ||
+ if (ret < 0) | ||
+ perror("mg_broadcast() recv failed, check firewall UDP loopback rules"); | ||
} | ||
} | ||
#endif /* MG_ENABLE_BROADCAST */ | ||
@@ -4116,9 +4119,12 @@ static void mg_mgr_handle_ctl_sock(struct mg_mgr *mgr) { | ||
struct ctl_msg ctl_msg; | ||
int len = | ||
(int) MG_RECV_FUNC(mgr->ctl[1], (char *) &ctl_msg, sizeof(ctl_msg), 0); | ||
- size_t dummy = MG_SEND_FUNC(mgr->ctl[1], ctl_msg.message, 1, 0); | ||
+ if (len < 0) | ||
+ perror("mg_mgr_handle_ctl_sock() recv failed, check firewall UDP loopback rules"); | ||
+ size_t ret = MG_SEND_FUNC(mgr->ctl[1], ctl_msg.message, 1, 0); | ||
+ if (ret < 0) | ||
+ perror("mg_mgr_handle_ctl_sock() send failed, check UDP loopback device"); | ||
DBG(("read %d from ctl socket", len)); | ||
- (void) dummy; /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 */ | ||
if (len >= (int) sizeof(ctl_msg.callback) && ctl_msg.callback != NULL) { | ||
struct mg_connection *nc; | ||
for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) { |