mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Fast fail mg_connect() if network is down
This commit is contained in:
1 parent
e86d4da129
commit
b10355a536
2 files changed
+8
No files matched your search
@@ -4673,6 +4673,10 @@ struct mg_connection *mg_connect_svc(struct mg_mgr *mgr, const char *url,
|
|||||||
struct mg_connection *c = NULL;
|
struct mg_connection *c = NULL;
|
||||||
if (url == NULL || url[0] == '\0') {
|
if (url == NULL || url[0] == '\0') {
|
||||||
MG_ERROR(("null url"));
|
MG_ERROR(("null url"));
|
||||||
|
#if MG_ENABLE_TCPIP
|
||||||
|
} else if (mgr->ifp != NULL && mgr->ifp->state != MG_TCPIP_STATE_READY) {
|
||||||
|
MG_ERROR(("Network is down"));
|
||||||
|
#endif
|
||||||
} else if ((c = mg_alloc_conn(mgr)) == NULL) {
|
} else if ((c = mg_alloc_conn(mgr)) == NULL) {
|
||||||
MG_ERROR(("OOM"));
|
MG_ERROR(("OOM"));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -173,6 +173,10 @@ struct mg_connection *mg_connect_svc(struct mg_mgr *mgr, const char *url,
|
|||||||
struct mg_connection *c = NULL;
|
struct mg_connection *c = NULL;
|
||||||
if (url == NULL || url[0] == '\0') {
|
if (url == NULL || url[0] == '\0') {
|
||||||
MG_ERROR(("null url"));
|
MG_ERROR(("null url"));
|
||||||
|
#if MG_ENABLE_TCPIP
|
||||||
|
} else if (mgr->ifp != NULL && mgr->ifp->state != MG_TCPIP_STATE_READY) {
|
||||||
|
MG_ERROR(("Network is down"));
|
||||||
|
#endif
|
||||||
} else if ((c = mg_alloc_conn(mgr)) == NULL) {
|
} else if ((c = mg_alloc_conn(mgr)) == NULL) {
|
||||||
MG_ERROR(("OOM"));
|
MG_ERROR(("OOM"));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user