mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
add: sig handler
This commit is contained in:
4
Makefile
4
Makefile
@@ -2,9 +2,9 @@ NAME = webserv
|
|||||||
|
|
||||||
CXX = clang++
|
CXX = clang++
|
||||||
|
|
||||||
SANFLAGS = -fsanitize=address
|
# SANFLAGS = -fsanitize=address
|
||||||
|
|
||||||
# SANFLAGS = -fsanitize=leak
|
SANFLAGS = -fsanitize=leak
|
||||||
|
|
||||||
DEBUGFLAGS = -g -fno-limit-debug-info
|
DEBUGFLAGS = -g -fno-limit-debug-info
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <wait.h>
|
#include <wait.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ void Server::add_to_epoll_list(int fd, unsigned int ep_events)
|
|||||||
<< ENDL;
|
<< ENDL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sigHandler(int sig)
|
||||||
|
{
|
||||||
|
if (sig == SIGINT)
|
||||||
|
throw ConfigException("SIGINT called. Server shutdown!");
|
||||||
|
}
|
||||||
|
|
||||||
void Server::start(void)
|
void Server::start(void)
|
||||||
{
|
{
|
||||||
/* Socket server_sock(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1"); */
|
/* Socket server_sock(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1"); */
|
||||||
@@ -198,7 +204,8 @@ void Server::start(void)
|
|||||||
|
|
||||||
unsigned int client_events = EPOLLIN;
|
unsigned int client_events = EPOLLIN;
|
||||||
unsigned int server_events = EPOLLIN;
|
unsigned int server_events = EPOLLIN;
|
||||||
|
|
||||||
|
std::signal(SIGINT, sigHandler);
|
||||||
_epoll_fd = epoll_create(1337);
|
_epoll_fd = epoll_create(1337);
|
||||||
|
|
||||||
|
|
||||||
@@ -301,6 +308,7 @@ void Server::start(void)
|
|||||||
if (client_map[fd]->allSended())
|
if (client_map[fd]->allSended())
|
||||||
{
|
{
|
||||||
delete_client(client_map, fd);
|
delete_client(client_map, fd);
|
||||||
|
// throw ConfigException("END!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,9 +436,9 @@ void Server::clean_parsed(TOMLMap *root)
|
|||||||
DBOUT << ">>> cleaning up: <<<" << std::endl;
|
DBOUT << ">>> cleaning up: <<<" << std::endl;
|
||||||
for (it = root->begin(); it != root->end(); ++it)
|
for (it = root->begin(); it != root->end(); ++it)
|
||||||
{
|
{
|
||||||
DBOUT << RED << it->first
|
// DBOUT << RED << it->first
|
||||||
<< ": " << GREEN
|
// << ": " << GREEN
|
||||||
<< *(it->second->toString());
|
// << *(it->second->toString());
|
||||||
|
|
||||||
clean_generic(it->second);
|
clean_generic(it->second);
|
||||||
/* delete it->second; */
|
/* delete it->second; */
|
||||||
|
|||||||
Reference in New Issue
Block a user