Skip to content

Commit 9d71cee

Browse files
committed
If the server has never been initialized, it should not be taking locks. Thanks to ycaibb for reporting! Although this was not their actual issue, it should still be fixed.
#10
1 parent f2b82a5 commit 9d71cee

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

EmbeddableWebServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,11 +1505,11 @@ void serverInit(struct Server* server) {
15051505
}
15061506

15071507
void serverStop(struct Server* server) {
1508-
serverMutexLock(server);
15091508
if (!server->initialized) {
15101509
ews_printf("Warning: Server %p was never initialized and you tried to stop it. Ignoring...\n", server);
15111510
return;
15121511
}
1512+
serverMutexLock(server);
15131513
server->shouldRun = false;
15141514
if (server->listenerfd >= 0) {
15151515
close(server->listenerfd);

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# EWS - Single .h File C Embeddable Web Server #
2-
Latest Version: 1.1.3 released May, 2020<br>
2+
Latest Version: 1.1.4 released September 9, 2021<br>
33
Supported platforms: Linux, Mac OS X, Windows<br>
44
License: BSD 2-clause<br>
55

@@ -105,6 +105,9 @@ Since EWS uses threads we need to have a way to launch threads on all platforms.
105105
* [Baraccuda](https://realtimelogic.com/products/barracuda-application-server/) - Baraccuda from Real-Time logic is a proprietary web server targetting embedded systems. I think they run with and without an OS and include lots of features like Mongoose does.
106106

107107
## Change log ##
108+
### 1.1.4 ###
109+
* Fixes https://github.com/hellerf/EmbeddableWebServer/issues/10 (serverStop should not take lock if not initialized)
110+
108111
### 1.1.3 ###
109112
* Fixes https://github.com/hellerf/EmbeddableWebServer/issues/7 (pathDecodedLength is always 0)
110113

@@ -124,3 +127,10 @@ Since EWS uses threads we need to have a way to launch threads on all platforms.
124127

125128
### 1.0 ###
126129
* Initial release
130+
131+
132+
## Things I would change ##
133+
If rewriting this from scratch I would change:
134+
* Right now all responses are allocated on the heap. They have to be built up into one single response. Instead I would allow for responses to be sent incrementally. So instead of responseAlloc you would have headerSend(connection, "Content-Type", "...") and bodySend("..."). It's a little more tricky to make that work and the onus of ordering goes on the user. Another advantage is that the user can deal with errors when sending pages.
135+
* Why did I not prefix all functions with something like EWS? EWSServerStart, EWSResponseAlloc. I should have done that. serverStop? Come on!
136+

0 commit comments

Comments
 (0)