#include "boa.h"
#include
/* globals */
int backlog = SO_MAXCONN; /*监听数目*/
time_t start_time; /*初始时间*/
int sighup_flag = 0; /* 1 => signal has happened, needs attention */
int sigchld_flag = 0; /* 1 => signal has happened, needs attention */
int sigalrm_flag = 0; /* 1 => signal has happened, needs attention */
int sigterm_flag = 0; /* lame duck mode */
time_t current_time; /*目前时间*/
int max_fd = 0;
int pending_requests = 0; /*处理请求标志*/
/* static to boa.c */
static void fixup_server_root(void); /*设置web server的根目录文件*/
static int create_server_socket(void); /*为web server创建套接字*/
static void drop_privs(void); /*运行boa需要root用户*/
static int sock_opt = 1;
static int do_fork = 1;
int devnullfd = -1;
int main(int argc, char **argv)
{
int c; /* command line arg */
int server_s; /* boa socket */
/* set umask to u+rw, u-x, go-rwx */
c = umask(~0600); /*进程设置文件模式创建屏蔽字*/
if (c == -1) {
perror("umask");
exit(1);
}
devnullfd = open("/dev/null", 0); /*打开文件/dev/null,使用dup2准备将数据流输出到客户端*/
/* make STDIN and STDOUT point to /dev/null */
if (devnullfd == -1) {
DIE("can't open /dev/null");
}
if (dup2(devnullfd, STDIN_FILENO) == -1) {
DIE("can't dup2 /dev/nul
web服务器boa代码分析
最新推荐文章于 2024-04-21 09:38:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)