- 论坛徽章:
- 0
|
基本情况是这样的:
在400上我们写了一个C程序,程序名为RECVDQMA,该程序负责从6000接收交易请求,调用spawn后,进行一些简单处理,写入到DATAQ中。
在测试机上,我们做了大量交易测试,在下作业的时候都很快,没有任何问题。
但在生产机上,此作业的结束时间(下作业时)与作业的工作时间成正比,即作业工作几天后,下作业时,比较快就可以结束;作业工作几个月后,下作业时,处于END状态无法结束,生产情况为执行了ENDSBS后,RECVDQMA处于END状态无法结束的时间超过24小时,仍然无法结束。而且没有产生异常日志(SPOOLFILE显示“ RECVDQMA catcher: 6”,表明下作业时,RECVDQMA已经收到信号量6)。
源程序附在下面,请各位高手花小小时间帮忙指点一下,拜谢!
#include <stdio.h>;
#include <stdlib.h>;
#include <sys/socket.h>;
#include <netinet/in.h>;
#include <errno.h>;
#include <spawn.h>;
#include <recio.h>;
#include <xxdtaa.h>;
#include "DQLOGERR"
#include "DEFINVAR"
int sd, sd2=-1;
void catcher( int sig )
{
close( sd );
close( sd2 );
printf("RECVDQMA catcher: %d??/n", sig);
exit(1);
}
void main()
{
int rc ;
int addrlen=0,flag=1;
int spawn_fdmap??(1??);
char *spawn_argv??(3??),*spawn_envp??(1??);
char bkstu??(2??);
struct inheritance inherit;
struct sockaddr_in serveraddr;
char WorkName??(60??);
char Prg??(11??);
char Msg??(41??);
int num=0;
struct sigaction sigact;
_DTAA_NAME_T dtaname = {LOGDTAANAME, NEWDQLIB};
memset( bkstu, 0, sizeof(bkstu) );
QXXRTVDA(dtaname,1,1,bkstu);
spawn_argv??(1??)=bkstu;
spawn_argv??(0??)=bkstu;
sprintf(Prg,"%-10s","RECVDQMA" ;
init_para(1);
sprintf(WorkName,"%s/%s",LIBPATH,IDQWRK64);
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
sprintf(Msg,"%-40s","socket creat failed" ;
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA套接字错误!!!" ;
exit(-1);
}
sigemptyset(&sigact.sa_mask);
sigact.sa_flags=0;
sigact.sa_handler=catcher;
sigaction(SIGTERM, &sigact, NULL);
if ((rc=setsockopt(sd,SOL_SOCKET,SO_REUSEADDR,
(char *)&flag,sizeof(flag)))<0)
{
close(sd);
sprintf(Msg,"%-40s","set socket option failed" ;
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA套接字错误!!!" ;
exit(-1);
}
memset(&serveraddr, 0x00, sizeof(struct sockaddr_in));
serveraddr.sin_family = AF_INET;
serveraddr.sin_port = htons(ISPORT64);
serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
if ((rc = bind(sd, (struct sockaddr *)&serveraddr,
sizeof(serveraddr))) < 0)
{
close(sd);
sprintf(Msg,"%-40s","socket bind failed" ;
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA套接字错误!!!" ;
exit(-1);
}
if ((rc = listen(sd,10)) < 0)
{
close(sd);
sprintf(Msg,"%-40s","socket listen failed" ;
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA套接字错误!!!" ;
exit(-1);
}
while (2>;1)
{
if ((sd2 = accept(sd,(struct sockaddr *)&serveraddr,
&addrlen))<0)
{
close(sd2);
num++;
sprintf(Msg,"errno=%d,%-20s",errno,"accept failed" ;
if ( num < LONGTIMES )
dqlg_err("W",Prg,Msg);
else
{
num = 0;
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA接收呼叫失败!!!");
}
sleep(5);
continue;
}
num = 0;
memset(&inherit, 0, sizeof(inherit));
spawn_argv??(2??) = NULL;
spawn_envp??(0??) = NULL;
spawn_fdmap??(0??) = sd2;
rc = spawn(WorkName,1,spawn_fdmap, &inherit,
spawn_argv, spawn_envp);
if (rc < 0)
{
sprintf(Msg,"%-40s","spawn() failed");
dqlg_err("E",Prg,Msg);
snd_consl("系统RECVDQMA子程序调用失败!!!");
close(sd2);
close(sd);
exit(-1);
}
close(sd2);
}
close(sd);
exit(0);
} |
|