Просмотр исходного кода

Merge pull request #193 from jmucchiello/master

added public mg_is_context_stopped() function
bel2125 10 лет назад
Родитель
Сommit
d7acd43548
2 измененных файлов с 16 добавлено и 0 удалено
  1. 10 0
      include/civetweb.h
  2. 6 0
      src/civetweb.c

+ 10 - 0
include/civetweb.h

@@ -743,6 +743,16 @@ CIVETWEB_API int mg_get_response(struct mg_connection *conn,
 CIVETWEB_API unsigned mg_check_feature(unsigned feature);
 
 
+/* Get the stopping status of a given civetweb context.
+
+   Return:
+    0: context is running normally
+	1: context is shutting down
+	2: context has stopped
+   -1: Invalid context
+ */
+CIVETWEB_API int mg_is_ctx_stopped(const struct mg_context* ctx);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

+ 6 - 0
src/civetweb.c

@@ -10787,6 +10787,12 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
 	return ctx;
 }
 
+int mg_is_ctx_stopped(const struct mg_context* ctx)
+{
+	if (!ctx) return -1;
+
+	return ctx->stop_flag;
+}
 
 /* Feature check API function */
 unsigned mg_check_feature(unsigned feature)