1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
This commit is contained in:
wreuven 2025-03-03 23:54:17 +08:00 committed by GitHub
commit a843d51422
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 49 additions and 1 deletions

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": true
}

View file

@ -710,6 +710,7 @@ lws_fx_string(const lws_fx_t *a, char *buf, size_t size);
#if defined(LWS_ROLE_MQTT)
#include <libwebsockets/lws-mqtt.h>
#endif
#include <libwebsockets/lws-assert.h>
#include <libwebsockets/lws-client.h>
#include <libwebsockets/lws-http.h>
#include <libwebsockets/lws-spa.h>

View file

@ -0,0 +1,21 @@
#if !defined(__LWS_ASSERT_H__)
#define __LWS_ASSERT_H__
typedef void (*lws_assert_cb)(const char *file, int line, const char *expression);
void lws_set_assert_cb(lws_assert_cb cb);
#ifdef LWS_ENABLE_CUSTOM_ASSERT
void lws_assert(const char *file, int line, const char *expression);
# ifdef assert
# undef assert
# endif
#define assert(expression) (void)((expression) || (lws_assert(__FILE__, __LINE__, #expression), 0))
#endif
#endif

View file

@ -32,6 +32,7 @@ if (NOT LWS_ONLY_SSPC)
list(APPEND SOURCES
core/alloc.c
core/assert.c
core/buflist.c
core/context.c
core/lws_map.c

16
lib/core/assert.c Normal file
View file

@ -0,0 +1,16 @@
#include "private-lib-core.h"
static lws_assert_cb assert_cb = NULL;
void lws_set_assert_cb(lws_assert_cb cb) {
assert_cb = cb;
}
void lws_assert(const char *file, int line, const char *expression) {
if (assert_cb != NULL) {
assert_cb(file, line, expression);
} else {
fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", expression, file, line);
abort();
}
}

View file

@ -147,6 +147,7 @@
*
*/
#define LWS_ENABLE_CUSTOM_ASSERT
#include "libwebsockets.h"
/*

View file

@ -286,7 +286,7 @@ hs2:
lwsl_debug("ERROR writing to client socket\n");
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,
"cws");
return 0;
return -1; // closed wsi so let callers know
case LWS_SSL_CAPABLE_MORE_SERVICE:
lws_callback_on_writable(wsi);
break;

5
make.sh Executable file
View file

@ -0,0 +1,5 @@
rm -rf build
mkdir build
cd build
cmake .. -DLWS_WITH_MINIMAL_EXAMPLES=1
make