|
|
@@ -2270,7 +2270,10 @@ void mg_http_reply(struct mg_connection *c, int code, const char *headers,
|
|
|
const char *fmt, ...) {
|
|
|
va_list ap;
|
|
|
size_t len;
|
|
|
-
|
|
|
+ if (c==NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// mg_printf(c, "HTTP/1.1 %d %s\r\n%sContent-Length: \r\n\r\n", code,
|
|
|
// mg_http_status_code_str(code), headers == NULL ? "" : headers);
|
|
|
mg_printf(c, "HTTP/1.1 %d %s\r\n"
|
|
|
@@ -2282,15 +2285,12 @@ mg_printf(c, "HTTP/1.1 %d %s\r\n"
|
|
|
"X-Frame-0ptions:: SAMEORIGIN\n"
|
|
|
"X-Xss-Protection: 1: mode=block\n"
|
|
|
"Accept-Ranges: bytes\n"
|
|
|
- "Vary: Accept-Encoding\n"
|
|
|
- "Access-Control-Allow-Origin: *\n"
|
|
|
- "Access-Control-Allow-Methods: *\n"
|
|
|
- "Access-Control-Allow-Headers: *\n\n"
|
|
|
- "%s\n", code, mg_http_status_code_str(code),strlen(fmt), fmt == NULL ? "" : fmt);
|
|
|
+ "Vary: Accept-Encoding\n\n"
|
|
|
+ "%s\n", code, mg_http_status_code_str(code),strlen(fmt == NULL ? "" : fmt), fmt == NULL ? "" : fmt);
|
|
|
|
|
|
len = c->send.len;
|
|
|
- va_start(ap, fmt);
|
|
|
- mg_vxprintf(mg_pfn_iobuf, &c->send, fmt, &ap);
|
|
|
+ va_start(ap, fmt == NULL ? "" : fmt);
|
|
|
+ mg_vxprintf(mg_pfn_iobuf, &c->send, fmt == NULL ? "" : fmt, &ap);
|
|
|
va_end(ap);
|
|
|
/*if (c->send.len > 16) {
|
|
|
size_t n = mg_snprintf((char *) &c->send.buf[len - 15], 11, "%-10lu",
|
|
|
@@ -4461,14 +4461,6 @@ void mg_mgr_free(struct mg_mgr *mgr) {
|
|
|
}
|
|
|
|
|
|
bool mg_mgr_init(struct mg_mgr *mgr) {
|
|
|
- // 初始化互斥锁
|
|
|
-
|
|
|
- #if MG_ARCH == MG_ARCH_UNIX
|
|
|
- if (pthread_mutex_init(&WSlock, NULL) != 0) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- #endif
|
|
|
-
|
|
|
memset(mgr, 0, sizeof(*mgr));
|
|
|
#if MG_ENABLE_EPOLL
|
|
|
if ((mgr->epoll_fd = epoll_create1(EPOLL_CLOEXEC)) < 0)
|