//--------------------------------------------------------- // Function: check // Description send the off command every so often so my water bill does not go sky high // Arguments: none // // Returns: nothing //--------------------------------------------------------- void check(void) { char checkresponse = '0'; logdebug("======Check======"); int retval = send_sprinkler_command(CMD_STATUS); if (retval != 0) { logerror("CMD_STATUS command failed"); gadgetrefresh(); }else { checkresponse = get_sprinkler_status(); loginfo("Status command result [%c]", checkresponse); if (checkresponse != '0') { loginfo("Sending off command"); retval = send_sprinkler_command(CMD_TOGGLE_ZONEOFF); if (retval != 0) { logerror("CMD_TOGGLE_ZONEOFF command failed"); /* may need to reboot the system here */ }else { loginfo("CMD_TOGGLE_ZONEOFF command completed without error"); } }else { loginfo("All zones off"); } } }
LIBDE265_API void de265_release_next_picture(de265_decoder_context* de265ctx) { decoder_context* ctx = (decoder_context*)de265ctx; // no active output picture -> ignore release request if (ctx->image_output_queue_length==0) { return; } loginfo(LogDPB, "release DPB with POC=%d\n",ctx->image_output_queue[0]->PicOrderCntVal); ctx->image_output_queue[0]->PicOutputFlag = false; // pop output queue for (int i=1;i<ctx->image_output_queue_length;i++) { ctx->image_output_queue[i-1] = ctx->image_output_queue[i]; } ctx->image_output_queue_length--; ctx->image_output_queue[ ctx->image_output_queue_length ] = NULL; loginfo(LogDPB, "DPB output queue: "); for (int i=0;i<ctx->image_output_queue_length;i++) { loginfo(LogDPB, "*%d ", ctx->image_output_queue[i]->PicOrderCntVal); } loginfo(LogDPB,"*\n"); }
QBBSd() { int udp_sock, tcp_sock; fd_set fdmask; if((udp_sock = udp_open(1)) < 0) logsyserr("<getconnect> could not get UDP socket"); if((tcp_sock = tcp_open(1)) < 0) logsyserr("<getconnect> could not get TCP socket"); loginfo("<quakebbs> QuakeBBS v%s Now Running!", QBBS_VERSION); for(;;) { loginfo("<quakebbs> Waiting for TCP connect on %d or UDP connect on %d", config.serv[0].port[0], config.serv[0].port[1]); FD_ZERO(&fdmask); FD_SET(udp_sock, &fdmask); FD_SET(tcp_sock, &fdmask); if(select(1+((tcp_sock > udp_sock) ? tcp_sock : udp_sock), &fdmask, (fd_set *)0, (fd_set *)0, (struct timeval *)0) < 0) logerr("<getconnect> select failed"); if(FD_ISSET(udp_sock, &fdmask)) udpconnect(udp_sock); if(FD_ISSET(tcp_sock, &fdmask)) tcpconnect(tcp_sock); } }
static void dump_packet(unsigned char *pkt, int len) { char left[64]; char right[20]; char tmp[8]; int n = 0; unsigned char *p=pkt; left[0]='\0'; loginfo("------dump packet(size=%d)------\n", len); while (p < pkt+len) { if (n%2==1) sprintf(tmp, "%02X ", *p); else sprintf(tmp, "%02X", *p); strcat(left, tmp); if (isprint(*p)) right[n] = *p; else right[n] = '.'; n = (n+1)%16; if (n==0){ right[16] = '\0'; loginfo("%s %s\n", left, right); left[0]='\0'; } p++; } if(n!=0){ right[n] = '\0'; loginfo("%s %s\n", left, right); } }
/** Close an output stream and destroy the objects. * * \param instance handle (i.e., pointer) to a BufferedWriter */ void bw_close(BufferedWriterHdl instance) { BufferedWriter *next, *self = (BufferedWriter*)instance; if(!self) return; if (oml_lock (&self->lock, "bw_close")) return; self->active = 0; loginfo ("Waiting for buffered queue reader thread to drain...\n"); pthread_cond_signal (&self->semaphore); oml_unlock (&self->lock, "bw_close"); // pthread_cond_destroy(&self->semaphore, NULL); switch (pthread_join (self->readerThread, NULL)) { case 0: loginfo ("Buffered queue reader thread finished OK...\n"); break; case EINVAL: logerror ("Buffered queue reader thread is not joinable\n"); break; case EDEADLK: logerror ("Buffered queue reader thread shutdown deadlock, or self-join\n"); break; case ESRCH: logerror ("Buffered queue reader thread shutdown failed: could not find the thread\n"); break; default: logerror ("Buffered queue reader thread shutdown failed with an unknown error\n"); break; } destroyBufferChain(self); xfree(self); }
void dump_compact_short_term_ref_pic_set(ref_pic_set* set, int range) { char *const log = (char *)alloca((range+1+range+1) * sizeof(char)); log[2*range+1] = 0; for (int i=0;i<2*range+1;i++) log[i]='.'; log[range]='|'; for (int i=set->NumNegativePics-1;i>=0;i--) { int n = set->DeltaPocS0[i]; if (n>=-range) { if (set->UsedByCurrPicS0[i]) log[n+range] = 'X'; else log[n+range] = 'o'; } else { loginfo(LogHeaders,"*%d ",n); } } for (int i=set->NumPositivePics-1;i>=0;i--) { int n = set->DeltaPocS1[i]; if (n<=range) { if (set->UsedByCurrPicS1[i]) log[n+range] = 'X'; else log[n+range] = 'o'; } else { loginfo(LogHeaders,"*%d ",n); } } loginfo(LogHeaders,"*%s\n",log); }
int main(int argc, const char *argv[]) { Socket* serverSock, *controlSock; int c; poptContext optCon = poptGetContext(NULL, argc, argv, options, 0); poptSetOtherOptionHelp(optCon, "configFile"); while ((c = poptGetNextOpt(optCon)) >= 0) { switch (c) { case 'v': printf(V_STRING, VERSION); printf(COPYRIGHT); return 0; } } setup_logging (logfile_name, log_level); if (c < -1) { /* an error occurred during option processing */ fprintf(stderr, "%s: %s\n", poptBadOption(optCon, POPT_BADOPTION_NOALIAS), poptStrerror(c)); return -1; } loginfo (V_STRING, VERSION); loginfo (COPYRIGHT); struct sigaction new_action, old_action; new_action.sa_handler = sigpipe_handler; sigemptyset (&new_action.sa_mask); new_action.sa_flags = 0; sigaction (SIGPIPE, NULL, &old_action); if (old_action.sa_handler != SIG_IGN) sigaction (SIGPIPE, &new_action, NULL); prepare_stdin(NULL); eventloop_init(); session = (Session*) malloc(sizeof(Session)); memset(session, 0, sizeof(Session)); session->state = ProxyState_PAUSED; serverSock = socket_server_new("proxy_server", listen_port, on_connect, NULL); controlSock = socket_server_new("proxy_server_control", listen_port + 1, on_control_connect, NULL); eventloop_on_stdin(stdin_handler, session); eventloop_run(); socket_free(serverSock); socket_free(controlSock); return(0); }
static int execute(void) { char *line = packet_buffer; int pktlen, len, i; char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT"); struct hostinfo hi; hostinfo_init(&hi); if (addr) loginfo("Connection from %s:%s", addr, port); set_keep_alive(0); alarm(init_timeout ? init_timeout : timeout); pktlen = packet_read(0, NULL, NULL, packet_buffer, sizeof(packet_buffer), 0); alarm(0); len = strlen(line); if (pktlen != len) loginfo("Extended attributes (%d bytes) exist <%.*s>", (int) pktlen - len, (int) pktlen - len, line + len + 1); if (len && line[len-1] == '\n') { line[--len] = 0; pktlen--; } if (len != pktlen) parse_host_arg(&hi, line + len + 1, pktlen - len - 1); for (i = 0; i < ARRAY_SIZE(daemon_service); i++) { struct daemon_service *s = &(daemon_service[i]); const char *arg; if (skip_prefix(line, "git-", &arg) && skip_prefix(arg, s->name, &arg) && *arg++ == ' ') { /* * Note: The directory here is probably context sensitive, * and might depend on the actual service being performed. */ int rc = run_service(arg, s, &hi); hostinfo_clear(&hi); return rc; } } hostinfo_clear(&hi); logerror("Protocol error: '%s'", line); return -1; }
static int execute(void) { char *line = packet_buffer; int pktlen, len, i; char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT"); if (addr) loginfo("Connection from %s:%s", addr, port); alarm(init_timeout ? init_timeout : timeout); pktlen = packet_read(0, NULL, NULL, packet_buffer, sizeof(packet_buffer), 0); alarm(0); len = strlen(line); if (pktlen != len) loginfo("Extended attributes (%d bytes) exist <%.*s>", (int) pktlen - len, (int) pktlen - len, line + len + 1); if (len && line[len-1] == '\n') { line[--len] = 0; pktlen--; } free(hostname); free(canon_hostname); free(ip_address); free(tcp_port); hostname = canon_hostname = ip_address = tcp_port = NULL; if (len != pktlen) parse_host_arg(line + len + 1, pktlen - len - 1); for (i = 0; i < ARRAY_SIZE(daemon_service); i++) { struct daemon_service *s = &(daemon_service[i]); int namelen = strlen(s->name); if (!prefixcmp(line, "git-") && !strncmp(s->name, line + 4, namelen) && line[namelen + 4] == ' ') { /* * Note: The directory here is probably context sensitive, * and might depend on the actual service being performed. */ return run_service(line + namelen + 5, s); } } logerror("Protocol error: '%s'", line); return -1; }
int StartRunningRA(int iIfindex) { char acIfname[IFNAMSIZ] = {0}; INTERFACE_RA_ST *p; FUNCBEGIN(); /* 应该先初始化然后将所有内容设置为1, 这里可以被移除 */ // ReInitInterface(iIfindex); p = FindInterfaceByIfindex(iIfindex); if (!p) { loginfo(FUNC, "args NULL"); return (-1); } if (NULL != if_indextoname(iIfindex, acIfname)) { loginfo(FUNC, "Now, begin to start ra config......\r\n\r\n\r\n\r\n"); SetAcceptRA(acIfname, 1); p->iFlags |= en_st_start; /* start of by d00107688 2010-01-26 增加支持是否允许添加默认路由 */ if (p->iDftRt) { SetAcceptDftRoute(acIfname, 1); } else { SetAcceptDftRoute(acIfname, 0); } /* end of by d00107688 2010-01-26 增加支持是否允许添加默认路由 */ SetAutoConf(acIfname, 1); } loginfo(FUNC, "start reinit interface [%d]", iIfindex); #if 0 /* 以防止在start之前已经被除了,因此重新初始化一下 */ ReInitInterface(iIfindex); p->iFlags |= en_st_start; #endif FUNCEND(); return (0); }
int ReInitInterface(int iIfIndex) { INTERFACE_RA_ST *p = NULL; FUNCBEGIN(); p = FindInterfaceByIfindex(iIfIndex); if (!p) { loginfo(FUNC, "args NULL"); return (-1); } ClearDNSInfo(&p->stRAData); ClearRAPrefix(&p->stRAData); ClearDftRoute(&p->stRAData); //p->iState = loginfo(FUNC, "begin to stop dhcp6c......"); if ((p->stRAData.iDhcpStatus & enMDHCP) || (p->stRAData.iDhcpStatus & enODHCP)) { loginfo(FUNC, "now, begin to stop dhcp6c........"); StopDhcp6c(p->iIfindex, 0); } loginfo(FUNC, "over................"); /* 所有统计信息初始化 */ p->iFlags = 0; p->iRSNum = 0; p->stRAData.iDftRtNum = 0; p->stRAData.iDnsNum = 0; p->stRAData.iPrefixNum = 0; p->stRAData.iManaged = 0; p->stRAData.iOtherInfo = 0; p->stRAData.iMOChg = 0; p->stRAData.iDhcpStatus = enNothing; p->stRAData.pstDftRtList = NULL; p->stRAData.pstDNSList = NULL; p->stRAData.pstPrexList = NULL; FUNCEND(); return (0); }
/** Create a new out stream for writing into a local file. * * \param file destination file (oml_strndup()'d locally) * \return a new OmlOutStream instance * * \see oml_strndup */ OmlOutStream* file_stream_new(const char *file) { MString *dest; OmlFileOutStream* self = (OmlFileOutStream *)oml_malloc(sizeof(OmlFileOutStream)); memset(self, 0, sizeof(OmlFileOutStream)); loginfo ("File_stream: opening local storage file '%s'\n", file); if (strcmp(file, "stdout") == 0 || strcmp(file, "-") == 0) { self->f = stdout; } else { if ((self->f = fopen(file, "a+")) == NULL) { logerror ("Can't open local storage file '%s'\n", file); return 0; } } dest = mstring_create(); mstring_sprintf(dest, "file:%s", file); self->dest = (char*)oml_strndup (mstring_buf(dest), mstring_len(dest)); mstring_delete(dest); self->write = file_stream_write; self->close = file_stream_close; return (OmlOutStream*)self; }
void FusionMapper::removeAlignables() { FastaReader* ref = getRef(); if(ref == NULL) return ; vector<Sequence> seqs; // first pass to gather all sequences for(int i=0; i<mFusionMatchSize; i++) { for(int m=0; m< fusionMatches[i].size(); m++) { seqs.push_back(fusionMatches[i][m]->getRead()->mSeq); } } Matcher matcher(ref, seqs); int removed = 0; // second pass to remove alignable sequences for(int i=0; i<mFusionMatchSize; i++) { for(int m=fusionMatches[i].size()-1 ;m>=0; m--) { MatchResult* mr = matcher.match(fusionMatches[i][m]->getRead()->mSeq); if(mr != NULL) { //fusionMatches[i][m]->getRead()->mSeq.print(); //cout<<endl; //mr->print(); delete fusionMatches[i][m]; fusionMatches[i].erase(fusionMatches[i].begin() + m); removed++; } } } loginfo( string("removeAlignables: ") + string( int2str(removed ))); }
prtime () { char buf[STRINGLENGTH]; char relsufix[STRINGLENGTH]; long twhen; int f; if ((thisC->Cflags&CFURELSUF) && thisC->Crelease) (void) sprintf (relsufix,".%s",thisC->Crelease); else relsufix[0] = '\0'; if (chdir (thisC->Cbase) < 0) logerr ("Can't change to base directory %s for collection %s", thisC->Cbase,thisC->Cname); (void) sprintf (buf,FILEWHEN,thisC->Cname,relsufix); f = open (buf,O_RDONLY,0); if (f >= 0) { if (read(f,(char *)&twhen,sizeof(long)) != sizeof(long)) twhen = 0; (void) close (f); } else twhen = 0; (void) strcpy (buf,ctime (&twhen)); buf[strlen(buf)-1] = '\0'; loginfo ("Last update occurred at %s for collection %s", buf,thisC->Cname); }
int getcommod(commodtype **c, int commodnum) { struct stat buffer; if (commodnum <= 0) { return 0; } fstat(commoddata, &buffer); if ((buffer.st_size / sizeof(commodtype)) < commodnum) { return 0; } else { *c = (commodtype *)malloc(sizeof(commodtype)); if (!*c) { #ifdef ENROL printf("getcommod: Error in malloc\n"); #else loginfo(ERRORLOG, WANTERRNO, "FATAL: Malloc failure [getcommod]"); #endif exit(1); } Fileread(commoddata, (char *)*c, sizeof(commodtype), (commodnum - 1) * sizeof(commodtype)); return 1; } }
int getship(shiptype **s, int shipnum) { struct stat buffer; if (shipnum <= 0) { return 0; } fstat(shdata, &buffer); if ((buffer.st_size / sizeof(shiptype)) < shipnum) { return 0; } else { *s = (shiptype *)malloc(sizeof(shiptype)); if (!*s) { #ifdef ENROL printf("getship: Error in malloc\n"); #else loginfo(ERRORLOG, WANTERRNO, "FATAL: Malloc failure [getship]"); #endif exit(1); } Fileread(shdata, (char *)*s, sizeof(shiptype), (shipnum - 1) * sizeof(shiptype)); return 1; } }
int getsector(sectortype **s, planettype *p, int x, int y) { int filepos; filepos = p->sectormappos + (((y * p->Maxx) + x) * sizeof(sectortype)); *s = (sectortype *)malloc(sizeof(sectortype)); if (!*s) { #ifdef ENROL printf("getsector: Error in malloc\n"); #else loginfo(ERRORLOG, WANTERRNO, "FATAL: Malloc failure [getsector]"); #endif exit(1); } if (!Fileread(sectdata, (char *)*s, sizeof(sectortype), filepos)) { free(*s); return FAIL; } else { return SUCCESS; } }
int libvirt_connect(int driver) { if (g_conn != NULL) { logwarn(_("conneted already.\n")); return -1; } virSetErrorFunc(NULL, __customErrorFunc); const char * URI; if (driver == HYPERVISOR_IS_KVM) URI = HYPERVISOR_URI_KVM; else if (driver == HYPERVISOR_IS_XEN) URI = HYPERVISOR_URI_XEN; else { logerror(_("unrecognized hypervisor driver(%d).\n"), driver); return -1; } __this_lock(); g_conn = virConnectOpen(URI); __this_unlock(); if (g_conn == NULL) { logerror(_("Connet to %s error.\n"), URI); return -1; } else { loginfo(_("Connect to %s success!\n"), URI); } return 0; }
char *MemBuffer::Get( int size ) { AppInfo::Instance()->mGetMem ++; char * r = new char[size]; loginfo("### new %p",r ); return r; }
/** Close an output stream and destroy the objects. * * \param instance handle (i.e., pointer) to a BufferedWriter */ void bw_close(BufferedWriter* instance) { int *retval; BufferedWriter *self = (BufferedWriter*)instance; if(!self) { return; } if (oml_lock (&self->lock, __FUNCTION__)) { return; } self->active = 0; loginfo ("%s: Waiting for buffered queue thread to drain...\n", self->outStream->dest); pthread_cond_signal (&self->semaphore); oml_unlock (&self->lock, __FUNCTION__); if(pthread_join (self->readerThread, (void**)&retval)) { logwarn ("%s: Cannot join buffered queue reader thread: %s\n", self->outStream->dest, strerror(errno)); } else { if (1 == *retval) { logdebug ("%s: Buffered queue fully drained\n", self->outStream->dest); } else { logerror ("%s: Buffered queue did not fully drain\n", self->outStream->dest, *retval); } } self->outStream->close(self->outStream); destroyBufferChain(self); oml_free(self); }
// Create some logs void create_logs() { logtrace(1 << " logtrace"); logtraceEx(1 << " logtraceEx", std::make_shared<LogValExtraExample>("logtraceEx_", 100)); logdebug(2 << " logdebug"); logdebugEx(2 << " logdebugEx", std::make_shared<LogValExtraExample>("logdebugEx_", 200)); loginfo(3 << " loginfo"); loginfoEx(3 <<" loginfoEx", std::make_shared<LogValExtraExample>("loginfoEx_", 300)); logwarn(4 << " logwarn"); logwarnEx(4 << " logwarnEx", std::make_shared<LogValExtraExample>("logwarnEx_", 400)); logerror(5 << " logerror"); logerrorEx(5 << " logerrorEx", std::make_shared<LogValExtraExample>("logerrorEx_", 500)); logfatal(6 << " logfatal"); logfatalEx(6 << " logfatalEx", std::make_shared<LogValExtraExample>("logfatalEx_", 600)); // mylevel make_mylevel(); logging(makelevel(MyLevel1), "7 test MyLevel1", log_tools::get_pid(), __func__, __FILE__, __LINE__); logging(makelevel(MyLevel2), "7 test MyLevel2", log_tools::get_pid(), __func__, __FILE__, __LINE__, std::make_shared<LogValExtraExample>("test MyLevel2", 700)); }
int handleaccept(int efd, int fd) { char logbuf[256]; char addrbuf[64]; struct sockaddr_in sain; socklen_t sl = sizeof(sain); int requestfd; while(1){ requestfd = accept(fd,(struct sockaddr *)&sain,&sl); if(requestfd == -1){ if(errno == EINTR) continue; else break; } else{ inet_ntop(AF_INET, &sain.sin_addr, addrbuf, sizeof(addrbuf)); sprintf(logbuf, "recieve a request from %s.\n", addrbuf); loginfo(logbuf); setnonblock(requestfd); if(addtoepoll(efd, requestfd, ETINOUT) != 0){ logwarn("epoll add request fd error.\n"); close(requestfd); continue; } } } return 0; }
INTERFACE_RA_ST *FindInterfaceByIfindex(int iIfindex) { INTERFACE_RA_ST *p = NULL; FUNCBEGIN(); if (!g_pstIfList) { loginfo(FUNC, "all list is NULL"); return (NULL); } p = g_pstIfList; for (; p; p = p->pstNext) { if (iIfindex == p->iIfindex) { return (p); } } FUNCEND(); return (NULL); }
int _send_dialog_packet(struct drcom_socks *socks, void *buf, uint16_t type) { struct drcom_request req, *request=&req; int len, r; switch (type) { case PKT_REQUEST: len = sizeof(struct drcom_request); memset(request, 0, sizeof(struct drcom_request)); request->host_header.pkt_type = PKT_REQUEST; request->host_header.zero = 0; request->host_header.len = 4; request->host_header.checksum[0] = 1; buf = (void *) request; loginfo("send: PKT_REQUEST\n"); break; case PKT_LOGIN: len = sizeof(struct drcom_login_packet); loginfo("send: PKT_LOGIN\n"); break; case PKT_LOGOUT: len = sizeof(struct drcom_logout_packet); loginfo("send: PKT_LOGOUT\n"); break; case PKT_PASSWORD_CHANGE: len = sizeof(struct drcom_passwd_packet); loginfo("send: PKT_PASSWD_CHANGE\n"); break; default: loginfo("send: Unknown PKT\n"); return -2; break; } r = sendto(socks->sockfd, buf, len, 0, (struct sockaddr *) &socks->servaddr_in, sizeof(struct sockaddr)); if (r != len){ logerr("send:failed\n"); return -1; } return 0; }
/* 构造一个RS报文 */ int GenerateRSPacket(unsigned char *pszBuff, int *iLen, int iIfIndex) { struct nd_router_solicit *pstAddr = NULL; struct nd_opt_hdr *pstOptHdr = NULL; struct sockaddr stSockAddr; int iPacketLen = 0; unsigned char *ptr = NULL; if ((!pszBuff) || (!iLen) || (0 == iLen)) { loginfo(FUNC, "args error"); return (-1); } memset(pszBuff, 0, *iLen); pstAddr = (struct nd_router_solicit *)pszBuff; pstAddr->nd_rs_type = (ND_ROUTER_SOLICIT); pstAddr->nd_rs_code = 0; iPacketLen += sizeof(*pstAddr); if (0 != GetHWAddress(&stSockAddr, iIfIndex)) { loginfo(FUNC, "Get hw address error"); return (-1); } /* ppp接口,ND与IPv6 Over PPP都没有指出这种情况下RS应该填充什么option */ if (ARPHRD_PPP == stSockAddr.sa_family) { } else if (ARPHRD_ETHER == stSockAddr.sa_family) { pstOptHdr = (struct nd_opt_hdr *)(pstAddr + 1); pstOptHdr->nd_opt_type = 1; pstOptHdr->nd_opt_len = 1; memcpy((pstOptHdr + 1), &stSockAddr.sa_data, 6); iPacketLen += 8; } *iLen = iPacketLen; return (0); }
//--------------------------------------------------------- // // Function: send_sprinkler_command // Description: Wrapper for sendSprinklerZoneCommand // Arguments: int Command // // Returns: int int send_sprinkler_command(int command) { if (myconfig->app_config->inert) { loginfo("Daemon is inert, discarding sprinkler command [%d]", command); return EXIT_SUCCESS; } else { return sendSprinklerZoneCommand(command); } }
//--------------------------------------------------------- // // Function: get_sprinkler_status // Description: Wrapper for get_status_response; // Arguments: nothing // // Returns: char char get_sprinkler_status() { if(myconfig->app_config->inert) { loginfo("Daemon is inert, responding to status request with [0]"); return '0'; } else { return get_status_response(); } }
static int run_service(struct interp *itable, struct daemon_service *service) { const char *path; int enabled = service->enabled; loginfo("Request %s for '%s'", service->name, itable[INTERP_SLOT_DIR].value); if (!enabled && !service->overridable) { logerror("'%s': service not enabled.", service->name); errno = EACCES; return -1; } if (!(path = path_ok(itable))) return -1; /* * Security on the cheap. * * We want a readable HEAD, usable "objects" directory, and * a "git-daemon-export-ok" flag that says that the other side * is ok with us doing this. * * path_ok() uses enter_repo() and does whitelist checking. * We only need to make sure the repository is exported. */ if (!export_all_trees && access("git-daemon-export-ok", F_OK)) { logerror("'%s': repository not exported.", path); errno = EACCES; return -1; } if (service->overridable) { service_looking_at = service; service_enabled = -1; git_config(git_daemon_config, NULL); if (0 <= service_enabled) enabled = service_enabled; } if (!enabled) { logerror("'%s': service not enabled for '%s'", service->name, path); errno = EACCES; return -1; } /* * We'll ignore SIGTERM from now on, we have a * good client. */ signal(SIGTERM, SIG_IGN); return service->fn(); }
void check_conflicting_options(void) { #define FATAL_NOT_SPECIFIED(str) fatal("You didn't specified the `%s' " \ "option in netsukuku.conf", \ (str)); \ if (!server_opt.pid_file) FATAL_NOT_SPECIFIED("pid_file"); if (!server_opt.inet_hosts && server_opt.restricted) FATAL_NOT_SPECIFIED("internet_ping_hosts"); if (server_opt.restricted && server_opt.share_internet && !file_exist(server_opt.ip_masq_script)) fatal("ip_masquerade_script \"%s\" is inexistent", server_opt.ip_masq_script); if (server_opt.shape_internet && !file_exist(server_opt.tc_shaper_script)) fatal("tc_shaper_script \"%s\" is inexistent", server_opt.ip_masq_script); if (!server_opt.restricted && server_opt.inet_connection) fatal("inet_connection=1 but ntk_restricted_mode=0. If you " "want to be compatible with the Internet, " "set the restricted mode in the options"); if (!server_opt.restricted && (server_opt.share_internet)) fatal("You want to share your Internet connection," "but I am not running in restricted mode (-r), " "'cause I'm not sure of what you want... " "I'm aborting."); if (server_opt.share_internet && me.my_bandwidth < MIN_CONN_BANDWIDTH) fatal("You want to share your Internet connection but " "your bandwidth is just TOO small. Do not share " "it, or your connection will be saturated"); if (!server_opt.inet_connection && server_opt.share_internet) { loginfo("You want to share your Internet connection," "but `internet_connection' is set to 0." "We are assuming it is 1"); server_opt.inet_connection = 1; } if (server_opt.shape_internet && !server_opt.inet_connection) fatal("The Internet traffic shaping option is set, but " "the `internet_connection' is set to 0, please check " "your options."); #ifdef IPV6_DISABLED if (server_opt.inet_gw.family == AF_INET6) fatal("Ipv6 is not supported"); #endif }
//--------------------------------------------------------- // // Function: sighandler // Description Handles the signals we care about // Arguments: int signal // // Returns: nothing // //--------------------------------------------------------- void sighandler(int signal) { if (signal == SIGTERM) { loginfo("Received SIGTERM - cleaning up"); check(); free_config(myconfig); free(myconfig); exit(0); } else if (signal == SIGHUP) { loginfo("Received SIGHUP - re-reading configuration file [%s]", myconfig->app_config->conf); process_config(); } else if (signal == SIGINT) { loginfo("Received SIGINT - cleaning up"); check(); free_config(myconfig); free(myconfig); exit(0); } }