This commit is contained in:
Jordan Bancino 2022-08-12 21:30:03 -04:00
parent 30ae6586b2
commit 538412d1c2
3 changed files with 15 additions and 4 deletions

View file

@ -21,6 +21,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <NonPosix.h>
#include <HttpServer.h> #include <HttpServer.h>
#include <pthread.h> #include <pthread.h>
@ -64,7 +66,7 @@ HttpServerCreate(unsigned short port, unsigned int nThreads,
return NULL; return NULL;
} }
server->sd = socket(AF_INET, SOCK_STREAM, 0); server->sd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (server->sd < 0) if (server->sd < 0)
{ {
@ -129,7 +131,7 @@ HttpServerEventThread(void *args)
struct sockaddr_storage addr; struct sockaddr_storage addr;
socklen_t addrLen = sizeof(addr); socklen_t addrLen = sizeof(addr);
int connFd; int connFd;
int pollResult = poll(pollFds, 1, 60 * 1000); int pollResult = poll(pollFds, 1, 500);
if (pollResult < 0) if (pollResult < 0)
{ {

View file

@ -21,6 +21,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <NonPosix.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -37,8 +39,6 @@
#include <Config.h> #include <Config.h>
#include <HttpServer.h> #include <HttpServer.h>
#include <NonPosix.h>
HttpServer *httpServer = NULL; HttpServer *httpServer = NULL;
static void static void

View file

@ -54,6 +54,15 @@ extern int chroot(const char *);
extern int pledge(const char *, const char *); extern int pledge(const char *, const char *);
extern int unveil(const char *, const char *); extern int unveil(const char *, const char *);
/*
* OpenBSD requires that _BSD_SOURCE be set to use SOCK_NONBLOCK for
* some reason, even though from everything I can tell, SOCK_NONBLOCK
* is POSIX.
*/
#ifndef _BSD_SOURCE
#define _BSD_SOURCE
#endif
#endif #endif
#endif #endif