Minor bug fixes

This commit is contained in:
Nate Choe
2022-02-16 23:13:21 -06:00
parent 978a6cbfd7
commit c67dd38bf1
4 changed files with 19 additions and 4 deletions

View File

@@ -34,5 +34,5 @@ sitefiles also allow comments with #
* TLS * TLS
* ```key``` - The filepath of the private key to use if transport == TLS * ```key``` - The filepath of the private key to use if transport == TLS
* ```cert``` - The filepath of the certificate to use if transport == TLS * ```cert``` - The filepath of the certificate to use if transport == TLS
* ```timeout``` - The amount of time to wait for data before closing the connection in ms * ```timeout``` - The amount of time to wait for data before closing the connection in ms. A timeout of 0 means to wait infinitely. (default: 2000)
* ```library``` - the path of a library that is linked in during runtime if ```DYNAMIC_LINKED_PAGES```is set. * ```library``` - the path of a library that is linked in during runtime if ```DYNAMIC_LINKED_PAGES```is set.

View File

@@ -41,7 +41,7 @@ static void daemonize(char *pidfile) {
break; break;
default: default:
pidout = fopen(pidfile, "w"); pidout = fopen(pidfile, "w");
fprintf(pidout, "%d\n", getpid()); fprintf(pidout, "%d\n", pid);
fclose(pidout); fclose(pidout);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@@ -218,6 +218,7 @@ NULL
for (;;) { for (;;) {
Stream *stream = acceptStream(listener, O_NONBLOCK); Stream *stream = acceptStream(listener, O_NONBLOCK);
int lowestThread; int lowestThread;
createLog("Accepted stream");
if (stream == NULL) { if (stream == NULL) {
createLog("Accepting a stream failed"); createLog("Accepting a stream failed");
continue; continue;

View File

@@ -15,6 +15,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
@@ -22,6 +23,7 @@
#include <poll.h> #include <poll.h>
#include <unistd.h> #include <unistd.h>
#include <swebs/util.h>
#include <swebs/runner.h> #include <swebs/runner.h>
#include <swebs/sitefile.h> #include <swebs/sitefile.h>
#include <swebs/connections.h> #include <swebs/connections.h>
@@ -44,7 +46,19 @@ void *runServer(RunnerArgs *args) {
for (;;) { for (;;) {
int i; int i;
if (site->timeout == 0) {
poll(fds, connCount, -1);
}
else
poll(fds, connCount, site->timeout); poll(fds, connCount, site->timeout);
{
char log[200];
sprintf(log,
"poll() finished with %d connections and a timeout of %d ms",
connCount, site->timeout);
createLog(log);
}
for (i = 1; i < connCount; i++) { for (i = 1; i < connCount; i++) {
if (updateConnection(connections + i, site)) if (updateConnection(connections + i, site))

View File

@@ -193,7 +193,7 @@ Sitefile *parseSitefile(char *path) {
ret->type = TCP; ret->type = TCP;
ret->key = NULL; ret->key = NULL;
ret->cert = NULL; ret->cert = NULL;
ret->timeout = 0; ret->timeout = 2000;
ret->size = 0; ret->size = 0;
ret->content = malloc(allocatedLength * sizeof(SiteCommand)); ret->content = malloc(allocatedLength * sizeof(SiteCommand));
#if DYNAMIC_LINKED_PAGES #if DYNAMIC_LINKED_PAGES