mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-01 13:10:43 +00:00
Allow NULL handler for mg_bind and mg_connect
CL: Allow NULL handler for mg_bind and mg_connect PUBLISHED_FROM=4963d5c022c2c57dd03101d9c7e72ca910c3bb61
This commit is contained in:
1 parent
8f36597048
commit
23533b83a4
3 files changed
+37
-35
No files matched your search
+13
-4
@@ -877,6 +877,16 @@ struct mg_connection *mg_connect(struct mg_mgr *mgr, const char *address,
|
||||
return mg_connect_opt(mgr, address, MG_CB(callback, user_data), opts);
|
||||
}
|
||||
|
||||
void mg_ev_handler_empty(struct mg_connection *c, int ev,
|
||||
void *ev_data MG_UD_ARG(void *user_data)) {
|
||||
(void) c;
|
||||
(void) ev;
|
||||
(void) ev_data;
|
||||
#if MG_ENABLE_CALLBACK_USERDATA
|
||||
(void) user_data;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct mg_connection *mg_connect_opt(struct mg_mgr *mgr, const char *address,
|
||||
MG_CB(mg_event_handler_t callback,
|
||||
void *user_data),
|
||||
@@ -888,6 +898,8 @@ struct mg_connection *mg_connect_opt(struct mg_mgr *mgr, const char *address,
|
||||
|
||||
MG_COPY_COMMON_CONNECTION_OPTIONS(&add_sock_opts, &opts);
|
||||
|
||||
if (callback == NULL) callback = mg_ev_handler_empty;
|
||||
|
||||
if ((nc = mg_create_connection(mgr, callback, add_sock_opts)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -1001,10 +1013,7 @@ struct mg_connection *mg_bind_opt(struct mg_mgr *mgr, const char *address,
|
||||
opts.user_data = user_data;
|
||||
#endif
|
||||
|
||||
if (callback == NULL) {
|
||||
MG_SET_PTRPTR(opts.error_string, "handler is required");
|
||||
return NULL;
|
||||
}
|
||||
if (callback == NULL) callback = mg_ev_handler_empty;
|
||||
|
||||
MG_COPY_COMMON_CONNECTION_OPTIONS(&add_sock_opts, &opts);
|
||||
|
||||
|
||||
Reference in new issue
Block a user