Пример #1
0
static void wpool_init(WTHREAD *wp,int num)
{
int i;
	if(wp->QP) return;
	wp->QP=(Qpool *)malloc(num * sizeof(Qpool));
	if(!wp->QP) {
		ShowLog(1,"%s:QP malloc error!",__FUNCTION__);
		wp->poolnum=0;
		return;
	}
	wp->poolnum=num;
	for(i=0;i<wp->poolnum;i++) {
		wp->QP[i].queue=NULL;
		wp->QP[i].tid=0;
		pthread_mutex_init(&wp->QP[i].mut,NULL);
		pthread_cond_init(&wp->QP[i].cond,NULL);
	}
	
        i=pthread_attr_setdetachstate(&wp->attr,PTHREAD_CREATE_DETACHED);
        if(i) {
                ShowLog(1,"%s:can't set pthread attr PTHREAD_CREATE_DETACHED:%s",
			__FUNCTION__,strerror(i));
        }
//设置线程堆栈保护区 16K
        pthread_attr_setguardsize(&wp->attr,(size_t)(1024 * 16));

}
Пример #2
0
int main(int ac,char *av[])
{
int i;
struct rlimit sLimit;

//设置可以core dumpped
        sLimit.rlim_cur = -1;
        sLimit.rlim_max = -1;
        i=setrlimit(RLIMIT_CORE,(const struct rlimit *)&sLimit);

	if(ac>1){
		envcfg(av[1]);
	}
	sprintf(myshowid,"%s:%d",sc_basename(av[0]),getpid());
	Showid=myshowid;
	i=scpool_init(0);
	if(i<=0) {
		ShowLog(1,"scpool_init err=%d",i);
		return 1;
	}
	ShowLog(2,"scpool %d",i);
	TPOOL_srv(netinit,quit,scpool_check,sizeof(GDA));
	quit(0);
	return 0;
}
Пример #3
0
cbDebuggerPlugin::SyncEditorResult cbDebuggerPlugin::SyncEditor(const wxString& filename, int line, bool setMarker)
{
    if (setMarker)
    {
        EditorManager* edMan = Manager::Get()->GetEditorManager();
        for (int i = 0; i < edMan->GetEditorsCount(); ++i)
        {
            cbEditor* ed = edMan->GetBuiltinEditor(i);
            if (ed)
                ed->SetDebugLine(-1);
        }
    }
    FileType ft = FileTypeOf(filename);
    if (ft != ftSource && ft != ftHeader && ft != ftResource)
    {
        // if the line is >= 0 and ft == ftOther assume, that we are in header without extension
        if (line < 0 || ft != ftOther)
        {
            ShowLog(false);
            Log(_("Unknown file: ") + filename, Logger::error);
            InfoWindow::Display(_("Unknown file"), _("File: ") + filename, 5000);

            return SyncFileUnknown; // don't try to open unknown files
        }
    }

    cbProject* project = Manager::Get()->GetProjectManager()->GetActiveProject();
    ProjectFile* f = project ? project->GetFileByFilename(filename, false, true) : nullptr;

    wxString unixfilename = UnixFilename(filename);
    wxFileName fname(unixfilename);

    if (project && fname.IsRelative())
        fname.MakeAbsolute(project->GetBasePath());

    // gdb can't work with spaces in filenames, so we have passed it the shorthand form (C:\MYDOCU~1 etc)
    // revert this change now so the file can be located and opened...
    // we do this by calling GetLongPath()
    cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetLongPath());
    if (ed)
    {
        ed->Show(true);
        if (f && !ed->GetProjectFile())
            ed->SetProjectFile(f);
        ed->GotoLine(line - 1, false);
        if (setMarker)
            ed->SetDebugLine(line - 1);
        return SyncOk;
    }
    else
    {
        ShowLog(false);
        Log(_("Cannot open file: ") + filename, Logger::error);
        InfoWindow::Display(_("Cannot open file"), _("File: ") + filename, 5000);

        return SyncFileNotFound;
    }
}
Пример #4
0
//连接
static int sc_connect(pool *p1,resource *rs)
{
int ret=-1;
T_NetHead Head;
struct utsname ubuf;
char buf[200],*p,addr[20];
log_stu logs;

	rs->Conn.timeout=-1;
	ret=Net_Connect(&rs->Conn,&rs->cli,*p1->log.family?p1->family:NULL);
	if(ret) {
		rs->cli.Errno=errno;
		stptok(strerror(errno),rs->cli.ErrMsg,sizeof(rs->cli.ErrMsg),0);
		return -1;
	}
//login
	uname(&ubuf);
	p=buf;
	Head.O_NODE=LocalAddr(rs->Conn.Socket,addr);
	p+=sprintf(p,"%s|%s|%s,%s|||",p1->log.DEVID,p1->log.LABEL,
		ubuf.nodename,addr);
	rs->Conn.MTU=p1->log.MTU;
	Head.PROTO_NUM=0;
	Head.D_NODE=p1->log.NEXT_d_node;
	Head.ERRNO1=rs->Conn.MTU;
	Head.ERRNO2=Head.PKG_REC_NUM=0;
	Head.data=buf;
	Head.PKG_LEN=strlen(Head.data);
	ret=SendPack(&rs->Conn,&Head);
	ret=RecvPack(&rs->Conn,&Head);
	if(ret) {
		rs->cli.Errno=errno;
		stptok(strerror(errno),rs->cli.ErrMsg,sizeof(rs->cli.ErrMsg),0);
		disconnect(&rs->Conn);
		ShowLog(1,"%s:network error %d,%s",__FUNCTION__,rs->cli.Errno,rs->cli.ErrMsg);
		rs->cli.Errno=-1;
		return -2;
	}
	if(Head.ERRNO1 || Head.ERRNO2) {
		ShowLog(1,"%s:login error ERRNO1=%d,ERRNO2=%d,%s",__FUNCTION__,
			Head.ERRNO1,Head.ERRNO2,Head.data);
		disconnect(&rs->Conn);
		stptok(Head.data,rs->cli.ErrMsg,sizeof(rs->cli.ErrMsg),0);
		rs->cli.Errno=-1;
		return -3;
	}
	net_dispack(&logs,Head.data,log_tpl);
	strcpy(rs->cli.DBOWN,logs.DBOWN);
	strcpy(rs->cli.UID,logs.DBUSER);
//取服务名
	ret=init_svc_no(&rs->Conn);
	rs->cli.Errno=ret;
	*rs->cli.ErrMsg=0;
	return ret;
}
Пример #5
0
static int login_finish(T_Connect *conn,T_NetHead *NetHead)
{
char *cp;
T_SRV_Var *up=(T_SRV_Var *)conn->Var;
GDA *gp=(GDA *)up->var;
T_CLI_Var *clip;
char tmp[30],tmp1[256];

	unset_callback(up->TCB_no);
//	up->poolno=get_scpool_no(NetHead->D_NODE);
/* 怎么认证还得想办法
	cp=get_LABEL(up->poolno);
	if(!cp || strcmp(cp,logrec.label)) {
		sprintf(tmp1,"错误的DBLABEL %s",logrec.label);
		goto errret;
	}
*/
	if(!gp->server) {
		sprintf(tmp1,"%s:connect to server fault,TCB:%d",
			__FUNCTION__,up->TCB_no);
		ShowLog(1,"%s:Error:%s",__FUNCTION__,tmp1);
                NetHead->ERRNO1=-1;
                NetHead->ERRNO2=-1;
                NetHead->PKG_REC_NUM=0;
                NetHead->data=tmp1;
                NetHead->PKG_LEN=strlen(NetHead->data);
                SendPack(conn,NetHead);
                return 0; // fail
	}
	clip=(T_CLI_Var *)gp->server->Var;
	if(clip) {
//		stptok(clip->UID,up->SQL_Connect.UID,sizeof(up->SQL_Connect.UID),0);
//		stptok(clip->DBOWN,up->SQL_Connect.DBOWN,sizeof(up->SQL_Connect.DBOWN),0);
	}
ShowLog(5,"%s:TCB:%d,poolno=%d,Errno=%d",__FUNCTION__,up->TCB_no,up->poolno,clip->Errno);
	release_SC_connect(&gp->server,up->TCB_no,up->poolno);
	cp=tmp1;
	if(clip) cp+=sprintf(cp,"%s|%s|%s|%s|",
			gp->devid,gp->operid ,clip->UID,clip->DBOWN);

	else cp+=sprintf(cp,"%s|%s|||", gp->devid,gp->operid);
	cp+=sprintf(cp,"%s|%d|",rsecstrfmt(tmp,now_sec(),YEAR_TO_SEC),up->TCB_no);
	ShowLog(2,"%s:%s Login success",__FUNCTION__,tmp1);

	NetHead->data=tmp1;
	NetHead->PKG_LEN=strlen(NetHead->data);
	NetHead->ERRNO1=0;
	NetHead->ERRNO2=0;
	NetHead->PKG_REC_NUM=0;
    	SendPack(conn,NetHead);
	return 1;
}
Пример #6
0
void quit(int n)
{
	ShowLog(0,"quit %d!\n",n);
/***********************************
 * close logfile
 ***********************************/
	if(n<0) n=-n;
	wpool_free();
	scpool_free();
	tpool_free();
	ShowLog(-1,0);
	exit(n&255);
}
Пример #7
0
 void DatabaseConnectionWindow::ActivateWindow()
 {
     if(!_DatabaseConnectionDialog)
     {
         _DatabaseConnectionDialog = new DatabaseConnectionDialog();
         connect(_DatabaseConnectionDialog,SIGNAL(RunWithoutDatabase()),this,SIGNAL(ContinueWithoutDatabase()));
         connect(_DatabaseConnectionDialog,SIGNAL(Close()),this,SIGNAL(Cancel()));
         connect(_DatabaseConnectionDialog,SIGNAL(ShowLog()),this,SIGNAL(ShowLog()));
         if(NewLabel.length() > 0)
             _DatabaseConnectionDialog->SetLabel(NewLabel);
         _DatabaseConnectionDialog->show();
     }
 }
Пример #8
0
//归还数据库连接  
void release_SC_connect(T_Connect **Connect,int TCBno,int n)
{
int i,num;
pthread_t tid=pthread_self();
pool *pl;
resource *rs;
T_CLI_Var *clip;
//ShowLog(5,"%s:TCB:%d,poolno=%d",__FUNCTION__,TCBno,n);
	if(!Connect || !scpool || n<0 || n>=SCPOOLNUM) {
		ShowLog(1,"%s:TCB:%d,poolno=%d,错误的参数",__FUNCTION__,TCBno,n);
		return;
	}
	if(!*Connect) {
		ShowLog(1,"%s:TCB:%d,Conn is Empty!",__FUNCTION__,TCBno);
		return;
	}
	clip=(T_CLI_Var *)((*Connect)->Var);
	pl=&scpool[n];
	rs=pl->lnk;
	if(!rs) {
		ShowLog(1,"%s:无效的连接池[%d]",__FUNCTION__,n);
		return;
	}
	num=pl->resource_num;
	for(i=0;i<num;i++,rs++) if(TCBno==rs->TCBno) {
		if(0!=pthread_mutex_lock(&pl->mut)) {
			ShowLog(1,"%s:pool[%d].%d,TCB:%d,mutex error=%d,%s",
				__FUNCTION__,n,i,TCBno,errno,strerror(errno));
			return;
		}
if(*Connect != &rs->Conn) {
	ShowLog(1,"%s:TCB:%d,Connect not equal!",__FUNCTION__,TCBno);
}
if(clip != &rs->cli) {
	ShowLog(1,"%s:TCB:%d,clip not equal!",__FUNCTION__,TCBno);
}
		if(rs->cli.Errno==-1) {  //连接失效
ShowLog(1,"%s:scpool[%d].%d fail!",__FUNCTION__,n,i);
			disconnect(&rs->Conn);
		}
		rs->TCBno=-1;
		pthread_mutex_unlock(&pl->mut);
		pthread_cond_signal(&pl->cond); //如果有等待连接的线程就唤醒它 
  		rs->timestamp=now_usec();
		clip->Errno=0;
		*clip->ErrMsg=0;
		*Connect=NULL;
		if(log_level) ShowLog(log_level,"%s tid=%lu,TCB:%d,pool[%d].lnk[%d]",__FUNCTION__,
				tid,TCBno,n,i);
		return;
	}
ShowLog(1,"%s:在pool[%d]中未发现该TCBno:%d",__FUNCTION__,n,TCBno);
	clip->Errno=0;
	*clip->ErrMsg=0;
	*Connect=NULL;
}
Пример #9
0
static void showpack(int lever,char *str,int i)
{
int j,k;
char errbuf[512];
	while(i>64) {
		i-=64;
		k=0;
		for(j=0;j<64;j++) k+=sprintf(errbuf+k,"%02X ",*str++ & 255);
		ShowLog(lever,"%s",errbuf);
	}
	k=0;
	for(j=0;j<i;j++) k+=sprintf(errbuf+k,"%02X ",*str++ & 255);
	ShowLog(lever,"%s",errbuf);
}
Пример #10
0
//连接池监控 
void scpool_check()
{
int n,i,num;
pool *pl;
resource *rs;
INT64 now;
char buf[32];
T_Connect *conn=NULL;

	if(!scpool) return;
	now=now_usec();
	pl=scpool;

	for(n=0;n<SCPOOLNUM;n++,pl++) {
		if(!pl->lnk) continue;
		rs=pl->lnk;
		num=pl->resource_num;
		if(log_level) ShowLog(log_level,"%s:scpool[%d],num=%d",__FUNCTION__,n,num);
		pthread_mutex_lock(&pl->mut);
		for(i=0;i<num;i++,rs++) if(rs->TCBno<0) {
			if(rs->Conn.Socket>-1 && (now-rs->timestamp)>299000000) {
//空闲时间太长了     
				disconnect(&rs->Conn);
				rs->cli.Errno=-1;
				if(log_level)
					ShowLog(log_level,"%s:Close SCpool[%d].lnk[%d],since %s",__FUNCTION__,
					n,i,rusecstrfmt(buf,rs->timestamp,YEAR_TO_USEC));
			}
		} else {
			if(rs->Conn.Socket>-1 && (now-rs->timestamp)>299000000) {
//占用时间太长了     
				if(-1==get_TCB_status(rs->TCBno)) {
				//TCB已经结束,释放之
					if(log_level) ShowLog(log_level,"%s:scpool[%d].lnk[%d] TCB:%d to be release",
						__FUNCTION__,n,i,rs->TCBno);
					rs->cli.Errno=-1;
					conn=&rs->Conn;
					release_SC_connect(&conn,rs->TCBno,n);
				} else {
				    if(log_level) ShowLog(log_level,"%s:scpool[%d].lnk[%d] used by TCB:%d,since %s",
					__FUNCTION__,n,i,rs->TCBno,
					rusecstrfmt(buf,rs->timestamp,YEAR_TO_USEC));
				}
			}
		}
		pthread_mutex_unlock(&pl->mut);
	}
}
Пример #11
0
int scpool_MGR(int TCBno,int poolno,T_Connect **connp,int (*call_back)(T_Connect *,T_NetHead *))
{
int ret;
pthread_t *tp;

	if(TCBno<0) {
		ShowLog(1,"%s:bad TCB no!",__FUNCTION__);
		return -1;
	}
	ShowLog(3,"%s:get pool[%d],TCB_no=%d,tid:%lX,USEC=%llu",__FUNCTION__,
		poolno,TCBno,pthread_self(),now_usec());
	*connp=get_SC_connect(poolno,0);
	if(*connp == (T_Connect *)-1) {
		*connp=NULL;
		return -1;
	}
	if(*connp) {
		if((*connp)->only_do == (sdbcfunc)1) {
			(*connp)->only_do=call_back;
			TCB_add(NULL,TCBno); //加入到主任务队列
//ShowLog(5,"%s:tid=%lX,only_do=1,TCB_no=%d",__FUNCTION__,pthread_self(),TCBno);
			return 1;
		}
		return 0;
	}
	set_callback(TCBno,call_back,120);
	if(wpool.poolnum<=0) {
		ret=get_scpoolnum();
		pthread_mutex_lock(&wpool.mut);
		wpool_init(&wpool,ret);
		pthread_mutex_unlock(&wpool.mut);
	}
	if(poolno < 0 || poolno >= wpool.poolnum) {
		ShowLog(1,"%s:TCB_no=%d bad poolno %d,poolnum=%d",__FUNCTION__,
			TCBno,poolno,wpool.poolnum);
		return -1;
	}
	pthread_mutex_lock(&wpool.QP[poolno].mut);
	TCB_add(&wpool.QP[poolno].queue,TCBno);
	tp=&wpool.QP[poolno].tid;
	if(*tp==0) *tp=TCBno+1;
	pthread_mutex_unlock(&wpool.QP[poolno].mut);
//new thread
	if(*tp==(pthread_t)(TCBno+1)) {
		pthread_create(&wpool.QP[poolno].tid,&wpool.attr,wait_sc,(void *)(long)poolno);
	} else pthread_cond_signal(&wpool.QP[poolno].cond); //唤醒工作线程
	return 1;
}
Пример #12
0
int  N_SQL_Exec(T_Connect *connect,char *cmd)
{
T_CLI_Var *clip=(T_CLI_Var *)connect->Var;
T_NetHead nethead;
int i;
	nethead.PROTO_NUM=get_srv_no(connect->Var,"SQL_Exec");
	if(nethead.PROTO_NUM==1) {
		ShowLog(1,"%s:服务不存在",__FUNCTION__);
		return FORMATERR;
	}
	nethead.O_NODE=clip->ctx_id;
	nethead.D_NODE=get_d_node();
	nethead.ERRNO1=0;
	nethead.ERRNO2=(connect->status>0)?PACK_STATUS:0;
	nethead.PKG_REC_NUM=0;
	nethead.data=cmd;
	nethead.PKG_LEN=strlen(nethead.data);
	i=SendPack(connect,&nethead);
	if(i)return i;
	i=RecvPack(connect,&nethead);
//ShowLog(5,"SQL_Exec:ret=%d,errno1=%d,len=%d:%s",i,nethead.ERRNO1,nethead.PKG_LEN,nethead.data);
	if(i){
		return i;
	}
	EventCatch(connect,nethead.PROTO_NUM);
	return GetError(connect,&nethead);
}
Пример #13
0
int CUploadsWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_bShowLog = TRUE; 
	
	if (FALSE == m_wndTasks.Create (this))
		return -1;

	if (FALSE == m_wndLog.Create (this))
		return -1;

	if (FALSE == m_wndSplitter.Create (AfxGetInstanceHandle (), m_hWnd, WST_HORIZONTAL))
		return -1;

	m_wndSplitter.SetWnd1 (m_wndTasks);
	m_wndSplitter.SetWnd2 (m_wndLog);
	m_wndSplitter.SetRatio (_App.View_SplitterRatio ("Uploads_T_L"));

	ShowLog (m_bShowLog);

	_UplsMgr.SetEventFunc (_UploadsMgrEvents, this);

	LoadAll ();
	m_wndTasks.OnUploadCountChanged ();

	SetTimer (1, 1000, NULL);
	
	return 0;
}
Пример #14
0
int  N_SQL_EndTran(T_Connect *connect,int TranFlag)
{
T_NetHead nethead;
T_CLI_Var *clip=(T_CLI_Var *)connect->Var;
int i;
	nethead.PROTO_NUM=get_srv_no(connect->Var,"SQL_EndTran");
	if(nethead.PROTO_NUM==1) {
		ShowLog(1,"%s:服务不存在",__FUNCTION__);
		return FORMATERR;
	}
	nethead.O_NODE=clip->ctx_id;
	nethead.D_NODE=get_d_node();
	if(TranFlag == TRANBEGIN) connect->status++;
	else connect->status--;
	nethead.ERRNO2=(connect->status>0)?PACK_STATUS:0;
	nethead.ERRNO1=TranFlag;
	nethead.PKG_REC_NUM=0;
	nethead.data=0;
	nethead.PKG_LEN=0;
	i=SendPack(connect,&nethead);
	if(i)return i;
	i=RecvPack(connect,&nethead);
	if(i)return i;
	EventCatch(connect,nethead.PROTO_NUM);
	return GetError(connect,&nethead);
}
Пример #15
0
int  N_SQL_Fetch(T_Connect *connect,int curno,char **data,int recnum)
{
T_CLI_Var *clip=(T_CLI_Var *)connect->Var;
T_NetHead nethead;
int i;
	nethead.PROTO_NUM=get_srv_no(connect->Var,"SQL_Fetch");
	if(nethead.PROTO_NUM==1) {
		ShowLog(1,"%s:服务不存在",__FUNCTION__);
		return FORMATERR;
	}
	nethead.O_NODE=clip->ctx_id;
	nethead.D_NODE=get_d_node();
	nethead.ERRNO2=PACK_STATUS;
	nethead.ERRNO1=curno;
/* recnum:进入时每次Fetch的记录数,0=全部记录,null=1条 */
	nethead.PKG_REC_NUM=recnum;
	nethead.data=0;
	nethead.PKG_LEN=0;
	i=SendPack(connect,&nethead);
	if(i<0)return i;
	i=RecvPack(connect,&nethead);
	if(i<0)return i;
	EventCatch(connect,nethead.PROTO_NUM);
	if(nethead.ERRNO1) return GetError(connect,&nethead);
	*data=nethead.data;
       	*((T_User_Var *)connect->Var)->ErrMsg=0;
       	((T_User_Var *)connect->Var)->Errno=nethead.ERRNO1;
/* colunm num */
	((T_User_Var *)connect->Var)->NativeError=nethead.ERRNO2;
/* 返回实际得到的记录数 */
	return nethead.PKG_REC_NUM;
}
Пример #16
0
void cbDebuggerPlugin::SwitchToDebuggingLayout()
{
    CodeBlocksLayoutEvent queryEvent(cbEVT_QUERY_VIEW_LAYOUT);

    const cbDebuggerConfiguration &config = GetActiveConfig();

    wxString perspectiveName;
    switch (cbDebuggerCommonConfig::GetPerspective())
    {
    case cbDebuggerCommonConfig::OnePerDebugger:
        perspectiveName = GetGUIName();
        break;
    case cbDebuggerCommonConfig::OnePerDebuggerConfig:
        perspectiveName = GetGUIName() + wxT(":") + config.GetName();
        break;
    case cbDebuggerCommonConfig::OnlyOne:
    default:
        perspectiveName = _("Debugging");
    }

    CodeBlocksLayoutEvent switchEvent(cbEVT_SWITCH_VIEW_LAYOUT, perspectiveName);

    Manager::Get()->GetLogManager()->DebugLog(F(_("Switching layout to \"%s\""), switchEvent.layout.wx_str()));

    // query the current layout
    Manager::Get()->ProcessEvent(queryEvent);
    m_PreviousLayout = queryEvent.layout;

    // switch to debugging layout
    Manager::Get()->ProcessEvent(switchEvent);

    ShowLog(false);
}
Пример #17
0
void cbDebuggerPlugin::OnCompilerFinished(cb_unused CodeBlocksEvent& event)
{
    if (m_WaitingCompilerToFinish)
    {
        m_WaitingCompilerToFinish = false;
        bool compilerFailed = false;
        // only proceed if build succeeeded
        if (m_pCompiler && m_pCompiler->GetExitCode() != 0)
        {
            AnnoyingDialog dlg(_("Debug anyway?"), _("Build failed, do you want to debug the program?"),
                               wxART_QUESTION, AnnoyingDialog::YES_NO, AnnoyingDialog::rtNO);
            if (dlg.ShowModal() != AnnoyingDialog::rtYES)
            {
                ProjectManager *manager = Manager::Get()->GetProjectManager();
                if (manager->GetIsRunning() && manager->GetIsRunning() == this)
                    manager->SetIsRunning(nullptr);
                compilerFailed = true;
            }
        }
        ShowLog(false);
        if (!CompilerFinished(compilerFailed, m_StartType))
        {
            ProjectManager *manager = Manager::Get()->GetProjectManager();
            if (manager->GetIsRunning() && manager->GetIsRunning() == this)
                manager->SetIsRunning(nullptr);
        }
    }
}
Пример #18
0
LRESULT CMainDlg::OnShowLog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
	CString* pStr = (CString *)wParam;
	ShowLog( pStr->GetBuffer(0));
	delete pStr;
	return 0;
}
Пример #19
0
/*---------------------------------------------------------------------------*/
void wxSQLBook::OnMnuCompactClick(wxCommandEvent& event)
{
    try
    {
        if (m_db->GetAutoCommit())
        {
            m_Hook->Clear();
            m_db->ExecuteUpdate(("VACUUM;"));
            DisplayHookValues();
            m_LogResult->AppendText(_("Operation completed.\n"));
        }
        else
        {
            wxMessageBox(_("A transaction is running.\n"
                           "You have to execute COMMIT or ROLLBACK "
                           "before compacting the database."),
                         _("Warning"));
        }
    }
    catch(wxSQLite3Exception& ex)
    {
        m_LogResult->AppendText(wxString::Format(_("Error %i-%i : %s\n"),
                                ex.GetErrorCode(),
                                ex.GetExtendedErrorCode(),
                                ex.GetMessage().c_str()));
        ShowLog();
    }
}
Пример #20
0
int  N_SQL_Select(T_Connect *connect,char *cmd,char **data,int num)
{
T_NetHead nethead;
T_CLI_Var *clip=(T_CLI_Var *)connect->Var;
int i;
	nethead.PROTO_NUM=get_srv_no(connect->Var,"SQL_Select");
	if(nethead.PROTO_NUM==1) {
		ShowLog(1,"%s:服务不存在",__FUNCTION__);
		return FORMATERR;
	}
	nethead.ERRNO1=0;
	nethead.ERRNO2=(connect->status>0)?PACK_STATUS:0;
	nethead.O_NODE=clip->ctx_id;
	nethead.D_NODE=get_d_node();
	nethead.PKG_REC_NUM=num;
	nethead.data=cmd;
	nethead.PKG_LEN=strlen(nethead.data);
	i=SendPack(connect,&nethead);
	if(i<0)return i;
	i=RecvPack(connect,&nethead);
	if(i<0)return i;
	EventCatch(connect,nethead.PROTO_NUM);
        *((T_User_Var *)connect->Var)->ErrMsg=0;
        ((T_User_Var *)connect->Var)->Errno=nethead.ERRNO1;
	*data=nethead.data;
	if(!nethead.ERRNO1) {
/* column num */
        	((T_User_Var *)connect->Var)->NativeError=nethead.ERRNO2;
		return nethead.PKG_REC_NUM;
	} else {
		return GetError(connect,&nethead);
	}
}
Пример #21
0
LRESULT CMainDlg::OnLoadWebsuc(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	std::string strUrl;
	std::string *precv = (std::string *)wParam;
	strUrl = *precv;
	ShowLog(strUrl, 2);
	delete precv;
	return 0;
}
Пример #22
0
void GameEnd(unsigned char team)
{
	ShowLog();
	if (team == 'a')
		Notice("The Alliance of Free Systems (Team Red) is victorious!");
	else if (team == 'b')
		Notice("The Galactic Empire (Team Blue) is victorious!");
	
	game.playing = false;
}
Пример #23
0
  MapReduceJob::~MapReduceJob()
  {

    if (messager        != NULL) delete messager;

	MPI_Barrier(MPI_COMM_WORLD);
	ShowLog("destroy MapReduce job and invoke MPI_Finalize");
    MPI_Finalize();

  }//MapReduceJob
Пример #24
0
char *decodeprepare(char *dblabel)
{
char *p;
DWS dw;
int ret;
/********************************************************************
 * 用户口令解密准备
 ********************************************************************/
	p=getenv("KEYFILE");
	if(!p||!*p) {
		ShowLog(1,"缺少环境变量 KEYFILE");
		ret=-1;
	} else {
		ret=initdw(p,&dw);
		if(ret) {
			ShowLog(1,"Init dw %s error %d",p,ret);
		}
	}
	if(dblabel && *dblabel) p=dblabel;
	else {
		p=getenv("DBLABEL");
		if(!p||!*p) {
			p=NULL;
			ret=-1;
		}
	}
	if(!ret) {
unsigned crc;
char *cp;
		crc=ssh_crc32((const unsigned char *)p,strlen(p));
		cp=getdw(crc,&dw);
		if(!cp) {
			freedw(&dw);
			ShowLog(1,"%s:无效的 KEYID %s",__FUNCTION__,p);
		} else {
			strcpy(keyid,cp);
			encryptproc=encryptpass;
		}
		freedw(&dw);
	}
	return p;
}
Пример #25
0
static void *wait_sc(void *para)
{
int ret,clr_q=0;
int poolno=(int)(long)para;
Qpool *qp=&wpool.QP[poolno];
int TCBno=-1;
T_Connect *conn=NULL;
pthread_t tid=pthread_self();
struct timespec tim;

	ShowLog(3,"%s:scpool[%d],tid=%lX created!",__FUNCTION__,poolno,tid);
	while(1) {
//从就绪队列取一个任务
		pthread_mutex_lock(&qp->mut);
		while(0>(TCBno=TCB_get(&qp->queue))) {
                        gettimeofday((struct timeval *)&tim,0);
                        tim.tv_sec+=300; //等待5分钟
                        tim.tv_nsec*=1000;
			clr_q=0;
                        ret=pthread_cond_timedwait(&qp->cond,&qp->mut,&tim); //没有任务,等待
                        if(ret)  {
				if(ETIMEDOUT != ret) 
				    ShowLog(1,"%s:pthread_cond_timedwait ret=%d,err=%d,%s",
					__FUNCTION__,ret,errno,strerror(errno));
				qp->tid=0;
				break;
			}
		};
		pthread_mutex_unlock(&qp->mut);
		if(TCBno<0) break;

		conn=NULL;
		if(!clr_q) {
			conn=get_SC_connect(poolno,5); //等待得到连接
			if(conn == (T_Connect *)-1) {
				clr_q=1; //清空队列
				conn=NULL;
				ShowLog(1,"%s:tid=%lX,get poolno[%d] fault for TCB:%d",
					__FUNCTION__,tid,poolno,TCBno);
			} else ShowLog(5,"%s[%d]:TCB:%d got connect!",__FUNCTION__,poolno,TCBno);
		}
		ret=bind_sc(TCBno,conn);
		if(ret<0) {
			if(conn) release_SC_connect(&conn,poolno);
			ShowLog(1,"%s:tid=%lX,bad bind connect to application!,TCB:%d,ret=%d",
				__FUNCTION__,tid,TCBno,ret);
		}
		ret=TCB_add(NULL,TCBno); //加入到主任务队列
		if(ret==-2) {
			unbind_sc(TCBno);
			release_SC_connect(&conn,poolno);
		}
if(clr_q) ShowLog(5,"%s[%d]:TCB:%d NULL to ready!,ret=%d",__FUNCTION__,poolno,TCBno,ret);
	}
	ShowLog(3,"%s[%d]:tid=%lX cancel!",__FUNCTION__,poolno,tid);
	return NULL;
}
Пример #26
0
 MapReduceJob::MapReduceJob(int & argc, char **& argv)
   : messager(NULL), commRank(-1), commSize(-1), deviceNum(-1)
 {
   int provided;
   MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
   MPI_Comm_rank(MPI_COMM_WORLD, &commRank);
   MPI_Comm_size(MPI_COMM_WORLD, &commSize);
   gCommRank = commRank;
   ShowLog("CommSize:%d",commSize);
   setDevice();
 }//MapReduceJob
Пример #27
0
int  N_SQL_Prepare(T_Connect *connect,char *cmd,T_SqlDa *sqlda)
{
T_CLI_Var *clip=(T_CLI_Var *)connect->Var;
T_NetHead nethead;
int i;
char *p;

	nethead.PROTO_NUM=get_srv_no(connect->Var,"SQL_Prepare");
	if(nethead.PROTO_NUM==1) {
		ShowLog(1,"%s:服务不存在",__FUNCTION__);
		return FORMATERR;
	}
	nethead.O_NODE=clip->ctx_id;
	nethead.D_NODE=get_d_node();
	nethead.ERRNO1=0;
	connect->status++;
	nethead.ERRNO2=PACK_STATUS;
	nethead.PKG_REC_NUM=0;
	nethead.data=cmd;
	nethead.PKG_LEN=strlen(nethead.data);
	i=SendPack(connect,&nethead);
	if(i) {
		connect->status--;
		return i;
	}
	i=RecvPack(connect,&nethead);
	if(i) {
		connect->status--;
		return i;
	}
	if((int)nethead.ERRNO1<0) {
		int ret=GetError(connect,&nethead);
		return ret;
	}
	sqlda->cursor_no=nethead.ERRNO1;
	sqlda->cols=nethead.PKG_REC_NUM;
	if(nethead.PKG_LEN>0) {
		sqlda->sqlvar=(T_SqlVar *)malloc(sizeof(T_SqlVar)*sqlda->cols);
		if(sqlda->sqlvar) {
		    p=nethead.data;
		    for(i=0;i<sqlda->cols;i++) {
			p+=net_dispack(&sqlda->sqlvar[i],p,SqlVarType);
		    }
		}
	} else sqlda->sqlvar=0;
       	((T_CLI_Var *)connect->Var)->Errno=0;
       	((T_CLI_Var *)connect->Var)->NativeError=nethead.PKG_REC_NUM;
        *((T_CLI_Var *)connect->Var)->ErrMsg=0;
	EventCatch(connect,nethead.PROTO_NUM);
	return 0;
}
Пример #28
0
HRESULT STDMETHODCALLTYPE CPopupMenu::InvokeCommand( __in CMINVOKECOMMANDINFO *pici)
{
	if(HIWORD(((CMINVOKECOMMANDINFOEX *)pici)->lpVerbW)){
		return S_OK;
	}
	else
	{
		if(1 == LOWORD(pici->lpVerb)){
			SetEnv();
		}
		else if(2 == LOWORD(pici->lpVerb)){
			Update();
		}
		else if(3 == LOWORD(pici->lpVerb)){
			Checkout();
		}
		else if(4 == LOWORD(pici->lpVerb)){
			Commit();
		}
		else if(5 == LOWORD(pici->lpVerb)){
			Checkin();
		}
		else if(6 == LOWORD(pici->lpVerb)){
			Cancel();
		}
		else if(7 == LOWORD(pici->lpVerb)){
			Add();
		}
		else if(8 == LOWORD(pici->lpVerb)){
			Revert();
		}
		else if(9 == LOWORD(pici->lpVerb)){
			Merge();
		}
		else if(10 == LOWORD(pici->lpVerb)){
			ShowLog();
		}
		else if(11 == LOWORD(pici->lpVerb)){
			Diff();
		}
		else if(12 == LOWORD(pici->lpVerb)){
			Compare();
		}
		else if(13 == LOWORD(pici->lpVerb)){
			UpdateRelyFiles();
		}
	}

	return S_OK;
}
Пример #29
0
int bind_sc(int TCBno,T_Connect *conn)
{
GDA *gp;

	gp=(GDA *)get_TCB_ctx(TCBno);
	if(gp==NULL) return -1;
	if(gp->server) {
		ShowLog(1,"%s:TCB:%d server not empty!",__FUNCTION__,TCBno);
		return -2;
	}
//	ShowLog(5,"%s:TCB:%d,conn=%016X,showid=%s",__FUNCTION__,TCBno,(long)conn,gp->ShowID);
	gp->server=conn;
	return 0;
}
Пример #30
0
int chkexec(char *str)
{
int i,cc;
regmatch_t pmatch[MATCHN];
char errbuf[128];
	if(!str) return -9999;
	i=strlen(str);
	if(i<1) return -9999;
	if(str[i-1]=='|') str[i-1]=0;
	if(!flg) {
		flg=1;
		for(i=0;i<BLKN;i++) {
			cc=regcomp(&blkname[i],black[i],REG_EXTENDED);
			if(cc) {
 				regerror(cc,&blkname[i],errbuf,sizeof(errbuf));
				ShowLog(1,"chkexec regcomp black %s:%s",
					black[i],errbuf);
				return -i-1;
			}
		}
		flg=2;
	}
	for(i=0;i<BLKN;i++) {
		cc=regexec(&blkname[i],str,MATCHN,pmatch,0);
		if(!cc) {
			ShowLog(1,"chkexec bad command %s:%d,%s",
						str,i+1,black[i]);
			return i+1;
		} else if(cc!=REG_NOMATCH) {
 			regerror(cc,&blkname[i],errbuf,sizeof(errbuf));
			ShowLog(1,"chkexec bad match %s:%d,%s",
					str,i+1,errbuf);
			return i+1;
		}
	}
	return 0;
}