refactor(server): remove myclib/socket include
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "utils/debug.h"
|
#include "utils/debug.h"
|
||||||
#include "utils/error.h"
|
#include "utils/error.h"
|
||||||
#include "utils/net.h"
|
#include "utils/net.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
static void cws_server_setup_hints(struct addrinfo *hints, const char *hostname) {
|
static void cws_server_setup_hints(struct addrinfo *hints, const char *hostname) {
|
||||||
memset(hints, 0, sizeof *hints);
|
memset(hints, 0, sizeof *hints);
|
||||||
@@ -125,7 +126,6 @@ cws_server_ret cws_server_start(cws_server_s *server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nfds; ++i) {
|
for (int i = 0; i < nfds; ++i) {
|
||||||
if (events[i].data.fd == server->sockfd) {
|
|
||||||
client_fd = cws_server_handle_new_client(server->sockfd);
|
client_fd = cws_server_handle_new_client(server->sockfd);
|
||||||
if (client_fd < 0) {
|
if (client_fd < 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -137,7 +137,6 @@ cws_server_ret cws_server_start(cws_server_s *server) {
|
|||||||
workers_index = (workers_index + 1) % CWS_WORKERS_NUM;
|
workers_index = (workers_index + 1) % CWS_WORKERS_NUM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return CWS_SERVER_OK;
|
return CWS_SERVER_OK;
|
||||||
}
|
}
|
||||||
@@ -176,11 +175,11 @@ void cws_server_shutdown(cws_server_s *server) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (server->sockfd > 0) {
|
if (server->sockfd > 0) {
|
||||||
sock_close(server->sockfd);
|
close(server->sockfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->epfd > 0) {
|
if (server->epfd > 0) {
|
||||||
sock_close(server->epfd);
|
close(server->epfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server->workers) {
|
if (server->workers) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ int http_get_content_type(char *location_path, char *content_type) {
|
|||||||
for (size_t i = 0; i < ARR_SIZE(mimetypes); ++i) {
|
for (size_t i = 0; i < ARR_SIZE(mimetypes); ++i) {
|
||||||
if (!strcmp(ptr, mimetypes[i].ext)) {
|
if (!strcmp(ptr, mimetypes[i].ext)) {
|
||||||
snprintf(content_type, CWS_HTTP_CONTENT_TYPE - 1, "%s", mimetypes[i].type);
|
snprintf(content_type, CWS_HTTP_CONTENT_TYPE - 1, "%s", mimetypes[i].type);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user