Browse Source

fix SILENT and choose_route

master
nicolas-arnaud 2 years ago
parent
commit
11c2d96571
  1. 2
      Makefile
  2. 1
      includes/webserv.hpp
  3. 13
      srcs/load/Server.cpp
  4. 2
      srcs/sock/Master.cpp

2
Makefile

@ -14,7 +14,7 @@ $(NAME): $(OBJS)
$(CXX) $(OBJS) -o $(NAME)
debug:
$(CXX) -I includes -Werror -Wextra -Wall -std=c++98 -g $(SRCS) -o $(NAME) -D DEBUG=1
$(CXX) -I includes -Werror -Wextra -Wall -std=c++98 -g $(SRCS) -o $(NAME) -D DEBUG=1 SILENT=0
verbose:
$(CXX) -I includes -Werror -Wextra -Wall -std=c++98 -g $(SRCS) -o $(NAME) -D SILENT=0

1
includes/webserv.hpp

@ -1,7 +1,6 @@
#pragma once
#ifndef DEBUG
#define DEBUG 0
#define SILENT 0
#endif
#ifndef SILENT
#define SILENT 1

13
srcs/load/Server.cpp

@ -1,4 +1,4 @@
/**
/*
* @file Server.cpp
* @brief The servers object. One is created for each config server.
* @author Narnaud
@ -87,14 +87,11 @@ Route *Server::choose_route(string uri) {
loc_words = split((*loc_it).first, "/");
vec_string::iterator loc_word = loc_words.begin();
vec_string::iterator uri_word = uri_words.begin();
while (uri_word != uri_words.end()) {
while (uri_word != uri_words.end() && *uri_word == "") uri_word++;
while (loc_word != loc_words.end() && *loc_word == "") loc_word++;
if (loc_word == loc_words.end()) return ((*loc_it).second);
if (*uri_word != *loc_word) break;
uri_word++;
loc_word++;
while (*loc_word == *uri_word) {
while (*++loc_word == "") {}
while (*++uri_word == "") {}
}
if (loc_word == loc_words.end()) return ((*loc_it).second);
}
return this;
}

2
srcs/sock/Master.cpp

@ -40,7 +40,7 @@ Master::Master(ip_port_t list) : _listen(list) {
#ifdef __APPLE__
fcntl(socket, F_SETFL, O_NONBLOCK);
#endif
if (!SILENT) cout << "New master socket with fd " << _fd << " which listen " << ip << ":" << port << "\n";
cout << "New master socket with fd " << _fd << " which listen " << ip << ":" << port << "\n";
_pollfds[_poll_id_amount].fd = _fd;
_pollfds[_poll_id_amount].events = POLLIN | POLLPRI;
_poll_id = _poll_id_amount;

Loading…
Cancel
Save