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

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

View File

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

View File

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