示例#1
0
/*
 * The administrator should be initialized to enable interpretation of
 * the command line arguments, before it starts servicing statements
 */
int
MCinitClientThread(Client c)
{
	Thread t;

	t = MT_thread_getdata();	/* should succeed */
	if (t == NULL) {
		MPresetProfiler(c->fdout);
		return -1;
	}
	/*
	 * The GDK thread administration should be set to reflect use of
	 * the proper IO descriptors.
	 */
	t->data[1] = c->fdin;
	t->data[0] = c->fdout;
	c->mythread = t;
	c->errbuf = GDKerrbuf;
	if (c->errbuf == NULL) {
		char *n = GDKzalloc(GDKMAXERRLEN);
		if ( n == NULL){
			MPresetProfiler(c->fdout);
			return -1;
		}
		GDKsetbuf(n);
		c->errbuf = GDKerrbuf;
	} else
		c->errbuf[0] = 0;
	return 0;
}
示例#2
0
/*
 * The administrator should be initialized to enable interpretation of
 * the command line arguments, before it starts serviceing statements
 */
int
MCinitClientThread(Client c)
{
	Thread t;
	char cname[11 + 1];

	snprintf(cname, 11, OIDFMT, c->user);
	cname[11] = '\0';
	t = THRnew(cname);
	if (t == 0) {
		showException(c->fdout, MAL, "initClientThread",
				"Failed to initialize client");
		MPresetProfiler(c->fdout);
		return -1;
	}
	/*
	 * The GDK thread administration should be set to reflect use of
	 * the proper IO descriptors.
	 */
	t->data[1] = c->fdin;
	t->data[0] = c->fdout;
	c->mythread = t;
	c->errbuf = GDKerrbuf;
	if (c->errbuf == NULL) {
		GDKsetbuf(GDKzalloc(GDKMAXERRLEN));
		c->errbuf = GDKerrbuf;
	} else
		c->errbuf[0] = 0;
	return 0;
}
示例#3
0
void
MCexitClient(Client c)
{
#ifdef MAL_CLIENT_DEBUG
	printf("# Exit client %d\n", c->idx);
#endif
	MPresetProfiler(c->fdout);
	if (c->father == NULL) { /* normal client */
		if (c->fdout && c->fdout != GDKstdout) {
			(void) mnstr_close(c->fdout);
			(void) mnstr_destroy(c->fdout);
		}
		assert(c->bak == NULL);
		if (c->fdin) {
			/* missing protection against closing stdin stream */
			(void) bstream_destroy(c->fdin);
		}
		c->fdout = NULL;
		c->fdin = NULL;
	}
}
示例#4
0
void
MCexitClient(Client c)
{
#ifdef MAL_CLIENT_DEBUG
	fprintf(stderr,"# Exit client %d\n", c->idx);
#endif
	finishSessionProfiler(c);
	MPresetProfiler(c->fdout);
	if (c->father == NULL) { /* normal client */
		if (c->fdout && c->fdout != GDKstdout) {
			close_stream(c->fdout);
		}
		assert(c->bak == NULL);
		if (c->fdin) {
			/* missing protection against closing stdin stream */
			bstream_destroy(c->fdin);
		}
		c->fdout = NULL;
		c->fdin = NULL;
	}
}