deallocate extension contexts on connection close
authorAndy Green <andy@warmcat.com>
Sun, 6 Mar 2011 10:29:38 +0000 (10:29 +0000)
committerAndy Green <andy@warmcat.com>
Sun, 6 Mar 2011 10:29:38 +0000 (10:29 +0000)
Signed-off-by: Andy Green <andy@warmcat.com>
lib/libwebsockets.c

index 39c537f..dded30e 100644 (file)
@@ -204,7 +204,20 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
                wsi->protocol->callback(context, wsi, LWS_CALLBACK_CLOSED,
                                                      wsi->user_space, NULL, 0);
 
-       /* free up his allocations */
+       /* deallocate any active extension contexts */
+
+       for (n = 0; n < wsi->count_active_extensions; n++) {
+               if (!wsi->active_extensions[n]->callback)
+                       continue;
+
+               wsi->active_extensions[n]->callback(context, wsi,
+                       LWS_EXT_CALLBACK_DESTROY,
+                       wsi->active_extensions_user[n], NULL, 0);
+
+               free(wsi->active_extensions_user[n]);
+       }
+
+       /* free up his parsing allocations */
 
        for (n = 0; n < WSI_TOKEN_COUNT; n++)
                if (wsi->utf8_token[n].token)