Exemplo n.º 1
0
/*
1> open shm
2> init pub
3> update activesys
4> on_app_start
   11>init core funtion
   12>update core function
   13>init function list
5> start local server
6> proccess request
   
   
*/
int main(int argc,char **argv){
		
	
	char *p;
	int  intMaxShmSize;
	int  intShmKey;
  msasPubInfo *ltPubInfo;
  lt_shmHead   *lt_MMHead;

  
  signal(SIGHUP,resetcatch_hup);
  signal(SIGCHLD, SIG_IGN);
	signal(SIGINT,  SIG_IGN);
	signal(SIGTERM, SIG_IGN);
	signal(SIGPIPE, SIG_IGN);
  

  
  /*读取最大共享内存数*/
	p=bcCnfGetValueS(pubconfdir,"kernel", "maxshmsize");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: maxshmsize is NULL!\n");
		die(51);
	}
	intMaxShmSize=atol(p);


	/*读取系统shmKey*/
	p=bcCnfGetValueS(pubconfdir,"kernel", "shmkey");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmkey is NULL!\n");
		die(52);
	} 
	intShmKey=atol(p);
	
	lt_MMHead=msasopenShmMem(intShmKey,intMaxShmSize);
	if(lt_MMHead==NULL){
		fprintf(stderr,"can open share memory!\n");
		die(53);
	}
  
   ltPubInfo=(msasPubInfo  *)lt_MMHead->ShmMemPtr;
	 if(ltPubInfo == NULL) {
	 	  fprintf(stderr,"can open share memory pubinfo!\n");
	    die(54);
	 }
	 
	
   msasInitPubVar(lt_MMHead);
	 


  /*加入其他执行程序*/

  lt_start_simple_server(lt_MMHead,pubconfdir,on_app,on_proc,on_proc_stop);
    
  return 0;
}
Exemplo n.º 2
0
int ltLocalServer(char *confFile){
    
    char *p;


    int  iReturn;
    /*读取配置信息并判断,如果不对返回错误*/
    if(confFile==NULL){
        fprintf(stderr,"Start tcp server error: the conf file is NULL!\n");
        return -1;  
    }

    /*设置消息包验证号*/
    p=bcCnfGetValueS(confFile,"kernel", "msgcheck");
    if(p==NULL){
        /*消息包验证号*/
        ltMsgSetValidCode(0);
    }else{
        ltMsgSetValidCode(atol(p));
    } 
    

    /*设置最大消息包*/
    p=bcCnfGetValueS(confFile,"kernel", "maxmsgpk");
    if(p==NULL){
        /*设置最大消息包*/
        lt_SetMaxTcpBuf(4096);
    }else{
        //ltMsgSetValidCode(atol(p));
        lt_SetMaxTcpBuf(atol(p));
    }   
    
    
    p=bcCnfGetValueS(confFile,"kernel", "servername");
    if(p==NULL){
        /*设置最大消息包*/
        p="/tmp/msascom";
    }   
    
        //iSock =lt_tcpserver(8000, 20);

    iReturn=lt_localserver(p);
  if(iReturn<0){
        return (-1);
  }

    return iReturn;
}
Exemplo n.º 3
0
lt_shmHead *createShmMem(unsigned int intShmKey,unsigned int intMaxShmSize){

	
	int shmid;
	struct shmid_ds shmbuf;
	void 	*shmMem;
	lt_shmHead *lt_MMHead;
	char  *p;
	int   intShmType;
	
	
	p=bcCnfGetValueS("/etc/gnm/conf","Shm", "shmtype");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmtype is NULL!\n");
		return NULL;	
	}
	intShmType=atol(p);
	
	if(intShmType==1){
    lt_MMHead=openBigBootMem(intMaxShmSize);
    return lt_MMHead;
  }
	
	if ((shmid = shmget(intShmKey, intMaxShmSize, (0666|IPC_CREAT))) == -1){
        fprintf(stderr, "failed to acquire shared memory segment\r\n");
        return NULL;
  }
  
  
        
  if ((shmMem = (void *)shmat(shmid, NULL, 0)) == ((void *)-1)){
        fprintf(stderr,"failed to attach shared memory");
         return NULL;
  }
  memset(shmMem,0,intMaxShmSize);
  if (shmctl(shmid, IPC_STAT, &shmbuf) == -1){
        fprintf(stderr, "failed to get status of shared memory");
         return NULL;
  }
  shmbuf.shm_perm.uid = getuid();
  shmbuf.shm_perm.gid = getgid();
  if (shmctl(shmid, IPC_SET, &shmbuf) == -1){
        fprintf(stderr, "failed to set status of shared memory");
        return NULL;	
  }
  
  lt_MMHead=(lt_shmHead *)malloc(sizeof(lt_shmHead));
  lt_MMHead->shmKey=intShmKey;
  lt_MMHead->intMaxShmSize=intMaxShmSize;
  lt_MMHead->shmid=shmid;
  lt_MMHead->ShmMemPtr=shmMem;
	return lt_MMHead;

}
Exemplo n.º 4
0
/*初始化系统参数、内存结构*/	
int ltStartApp(int sysActiveFlag){

	
	char *p;
	int  intMaxShmSize;
	int  intShmKey;
	
	
  pubconfdir=NULL;
  pubconfdir= getenv("RUNCONFDIR");
  if(!pubconfdir){
  	pubconfdir="/etc/msa/msas1";
  }
  
  /*读取最大共享内存数*/
	p=bcCnfGetValueS(pubconfdir,"kernel", "maxshmsize");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: maxshmsize is NULL!\n");
		return -1;	
	}
	intMaxShmSize=atol(p);

	/*读取系统shmKey*/
	p=bcCnfGetValueS(pubconfdir,"kernel", "shmkey");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmkey is NULL!\n");
		return -1;	
	} 
	intShmKey=atol(p);
	
	lt_MMHead=msascreateShmMem(intShmKey,intMaxShmSize);
  
	if(lt_MMHead){
		_ltPubInfo = (msasPubInfo *)lt_MMHead->ShmMemPtr;
    _ltPubInfo->sysActive=sysActiveFlag;
		return 0;
	}
	return -1;

}
Exemplo n.º 5
0
lt_shmHead *openShmMem(unsigned int intShmKey,unsigned int intMaxShmSize){


	int shmid;
	struct shmid_ds shmbuf;
	void 	*shmMem;
	lt_shmHead *lt_MMHead;
	char  *p;
	int   intShmType;
	
	
	p=bcCnfGetValueS("/etc/gnm/conf","Shm", "shmtype");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmtype is NULL!\n");
		return NULL;	
	}
	intShmType=atol(p);
	
	if(intShmType==1){
    lt_MMHead=openBigBootMem(intMaxShmSize);
    return lt_MMHead;
  }
	
	shmid = shmget(intShmKey, 0, 0);
	if (shmid == -1){
        fprintf(stderr, "failed to open shared memory segment\r\n");
        return NULL;	
  }
        
  if ((shmMem = (void *)shmat(shmid, NULL, 0)) == ((void *)-1)){
        fprintf(stderr,"failed to attach shared memory");
        return NULL;
  }
  
  
  lt_MMHead=(lt_shmHead *)malloc(sizeof(lt_shmHead));
  lt_MMHead->shmKey=intShmKey;
  lt_MMHead->intMaxShmSize=intMaxShmSize;
  lt_MMHead->shmid=shmid;
  lt_MMHead->ShmMemPtr=shmMem;
	return lt_MMHead;

}
Exemplo n.º 6
0
int closeShmMem(lt_shmHead *lt_MMHead){
  char  *p;
	int   intShmType;
	
	
	p=bcCnfGetValueS("/etc/gnm/conf","Shm", "shmtype");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmtype is NULL!\n");
		return 0;	
	}
	intShmType=atol(p);
	
	if(intShmType==1){
    closeBigBootMem(lt_MMHead);
    return 0;
  }
  shmdt((void *)lt_MMHead->ShmMemPtr);
  shmctl(lt_MMHead->shmid, IPC_RMID, NULL);
  free(lt_MMHead);
	return 0;

}
Exemplo n.º 7
0
int main(int argc,char *argv[])
{
    
    char  caCmd[256];
    pubconfdir=NULL;
	  pubconfdir= getenv("RUNCONFDIR");
	  if(!pubconfdir){
	  	pubconfdir="/etc/msa/msas2";
	  }
	  
	  /*读取最大共享内存数*/
   
    system("killall -9 msasLocalServer2");
    system("killall -9 msasMainProc2");
  
    
    sprintf(caCmd,"ipcrm -M %s",bcCnfGetValueS(pubconfdir,"kernel", "shmkey"));
    
    
    system(caCmd);
	
    return 0;
}
Exemplo n.º 8
0
int main(int argc,char *argv[])
{
    
    char  caCmd[256];

	  char *p;
	int  intMaxShmSize;
	int  intShmKey;
  msaPubInfo *ltPubInfo;
  lt_shmHead   *lt_MMHead;
   
  /*系统信号识别*/
  signal(SIGHUP,catch_hup);
  signal(SIGPIPE,SIG_IGN);
  signal(SIGCHLD,SIG_IGN);
  signal(SIGTERM,SIG_IGN);
  
  /*读取最大共享内存数*/
	p=bcCnfGetValueS(_pubconfdir,"kernel", "maxshmsize");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: maxshmsize is NULL!\n");
		die(51);
	}
	intMaxShmSize=atol(p);

	/*读取系统shmKey*/
	p=bcCnfGetValueS(_pubconfdir,"kernel", "shmkey");
	if(p==NULL){
		fprintf(stderr,"Start applicatin error: shmkey is NULL!\n");
		die(52);
	} 
	intShmKey=atol(p);
	
	lt_MMHead=msaopenShmMem(intShmKey,intMaxShmSize);
	if(lt_MMHead==NULL){
		fprintf(stderr,"can't open share memory!\n");
		die(53);
	}
  
  ltPubInfo=(msaPubInfo  *)lt_MMHead->ShmMemPtr;
	if(ltPubInfo == NULL) {
	 	  fprintf(stderr,"can't open share memory pubinfo!\n");
	    die(54);
	}
	 
  msaInitPubVar(lt_MMHead);
	  /*读取最大共享内存数*/
  
    semctl(_ltPubInfo->_dbusernamehead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_dbuseriphead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_dbusermachead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_onlineuserhead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_urlhashhead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_tcpsessionhead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_httpbufferhead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_dipbufferhead.locksemid,0, IPC_RMID, 0);
    semctl(_ltPubInfo->_2SrvInfohead.locksemid,0, IPC_RMID, 0);

    system("killall -9 msaLocalServer");
    system("killall -9 msaMainProc");
     
    sprintf(caCmd,"ipcrm -M %s",bcCnfGetValueS(_pubconfdir,"kernel", "shmkey"));    
    system(caCmd);
	
    return 0;
}