KeepAlived系列1:使用到的若干API

chdir---切换程序当前目录。

fork---生成两个进程,返回值我就不说了,太简单。

close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
if (setsid() == -1) exit(4);
作用是成为后台进程,这函数到处都是

sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
构造原始套接字

init_services 用来保证初始状态都OK,机器都启动

 

PrintLst 打印配置文件中的信息

result = setsockopt(sockfd, IPPROTO_IP, IP_FW_MASQ_CTL, (char *)&ctl, sizeof(ctl));
  if (errno == ESRCH) 
  { #ifdef DEBUG memset(debugmsg,0,LOGBUFFER_LENGTH);
    sprintf(debugmsg,"ipvs_pool_cmd : Virtual service [%s:%s] not defined.\n", vserver->addr_ip, vserver->addr_port); logmessage(debugmsg,getpid()); #endif close(sockfd);
    free(debugmsg);
    return IPVS_ERROR; } 
  else if (errno == ENOENT) 
  { #ifdef DEBUG memset(debugmsg,0,LOGBUFFER_LENGTH);
    sprintf(debugmsg,"ipvs_pool_cmd : No such destination %s\n",vserver->svr->addr_ip); logmessage(debugmsg,getpid()); #endif close(sockfd);
    free(debugmsg);
    return IPVS_ERROR; }
没搜到资料,估计是预检测系统是否都在运行

 

你可能感兴趣的:(keepalived)