Pārlūkot izejas kodu

Merge pull request #17 from bgreat/master

Implement connection_close() callback
sunsetbrew 12 gadi atpakaļ
vecāks
revīzija
794c4a2967
3 mainītis faili ar 7 papildinājumiem un 2 dzēšanām
  1. 1 1
      examples/websocket/websocket.c
  2. 5 0
      src/civetweb.c
  3. 1 1
      src/main.c

+ 1 - 1
examples/websocket/websocket.c

@@ -32,7 +32,7 @@ int main(void)
     struct mg_callbacks callbacks;
     const char *options[] = {
         "listening_ports", "8080",
-        "document_root", "websocket_html_root",
+        "document_root", "docroot",
         NULL
     };
 

+ 5 - 0
src/civetweb.c

@@ -5327,6 +5327,11 @@ static void close_socket_gracefully(struct mg_connection *conn)
 static void close_connection(struct mg_connection *conn)
 {
     mg_lock(conn);
+
+    // call the connection_close callback if assigned
+    if (conn->ctx->callbacks.connection_close != NULL)
+        conn->ctx->callbacks.connection_close(conn);
+
     conn->must_close = 1;
 
 #ifndef NO_SSL

+ 1 - 1
src/main.c

@@ -358,7 +358,7 @@ static void set_absolute_path(char *options[], const char *option_name,
         // be the relative directory for everything.
         // Extract civetweb executable directory into path.
         if ((p = strrchr(path_to_civetweb_exe, DIRSEP)) == NULL) {
-            getcwd(path, sizeof(path));
+            IGNORE_UNUSED_RESULT(getcwd(path, sizeof(path)));
         } else {
             snprintf(path, sizeof(path)-1, "%.*s", (int) (p - path_to_civetweb_exe),
                      path_to_civetweb_exe);