Beispiel #1
0
static void  updproc_stop(boolean_t exit)
{
	int4		status;
	int		fclose_res;

	call_on_signal = NULL;	/* Don't reenter on error */
	if (pool_init)
	{
		rel_lock(jnlpool.jnlpool_dummy_reg);
		/* nullify jnlpool_ctl before detaching from jnlpool since if it is the other way, we might be interrupted
		 * by the periodic timer routines and end up in jnl_write_epoch_rec() routine that dereferences jnlpool_ctl
		 * since it is non-NULL although it has been detached from and is no longer valid memory.
		 */
		jnlpool_ctl = NULL;
#ifdef UNIX
		mutex_cleanup(jnlpool.jnlpool_dummy_reg);
		SHMDT(jnlpool.jnlpool_ctl);
#elif defined(VMS)
		if (SS$_NORMAL != (status = detach_shm(jnlpool.shm_range)))
			repl_log(stderr, TRUE, TRUE, "Error detaching from jnlpool : %s\n", REPL_STR_ERROR);
		if (SS$_NORMAL != (status = signoff_from_gsec(jnlpool.shm_lockid)))
			repl_log(stderr, TRUE, TRUE, "Error dequeueing lock on jnlpool global section : %s\n", REPL_STR_ERROR);
#else
#error Unsupported Platform
#endif
		jnlpool.jnlpool_ctl = NULL;
		pool_init = FALSE;
	}
	recvpool.upd_proc_local->upd_proc_shutdown = NORMAL_SHUTDOWN;
	recvpool.upd_proc_local->upd_proc_pid = 0;
#ifdef UNIX
	SHMDT(recvpool.recvpool_ctl);
#elif defined(VMS)
	if(SS$_NORMAL != (status = detach_shm(recvpool.shm_range)))
		repl_log(stderr, TRUE, TRUE, "Update process could not detach from recvpool : %s\n", REPL_STR_ERROR);
	if (SS$_NORMAL != (status = signoff_from_gsec(recvpool.shm_lockid)))
		repl_log(stderr, TRUE, TRUE, "Error dequeueing lock on recvpool global section : %s\n", REPL_STR_ERROR);
#else
#error Unsupported Platform
#endif
	recvpool.recvpool_ctl = NULL;
	gtm_event_log_close();
	if (exit)
		mupip_exit(SS_NORMAL);
	return;
}
Beispiel #2
0
void buf_dt(struct buf_s *buf)
{
	if (!buf)
		return;
	if (buf->mapW)
		detach_shm(buf);
	else
		detach_mal(buf);
}
Beispiel #3
0
void buf_dtor(struct buf_s *buf)
{
	if (!buf)
		return;
	if (buf->mapW) {
		detach_shm(buf);
		rm_shm(buf);
	} else
		detach_mal(buf);
}
Beispiel #4
0
void end_routine(shm_struct *shm_str, plist_struct *plist_str, int shm_id, int plist_id){

   if (shm_str != NULL){detach_shm(shm_str);}
   if (plist_str != NULL){detach_plist(plist_str);}


   if (shm_id > 0){delete_by_shmid(shm_id);}
   if (plist_id > 0){delete_by_shmid(plist_id);}
  logPrnt('g', 'p', "\nDelete routine was executed!\n");

  exit(EXIT_SUCCESS);
}
Beispiel #5
0
/*ARGSUSED*/
CK_RV
SC_Finalize(void *argptr)
{
	CK_RV	  rc;
	TSS_HCONTEXT hContext;

	if (st_Initialized() == FALSE) {
		return (CKR_CRYPTOKI_NOT_INITIALIZED);
	}

	rc = pthread_mutex_lock(&pkcs_mutex);
	if (rc != CKR_OK) {
		return (rc);
	}
	//
	// If somebody else has taken care of things, leave...
	//
	if (st_Initialized() == FALSE) {
		(void) pthread_mutex_unlock(&pkcs_mutex);
		return (CKR_CRYPTOKI_NOT_INITIALIZED);
	}
	if (open_tss_context(&hContext)) {
		(void) pthread_mutex_unlock(&pkcs_mutex);
		return (CKR_FUNCTION_FAILED);
	}

	initialized = FALSE;

	if (token_specific.t_final != NULL) {
		token_specific.t_final(hContext);
	}

	(void) session_mgr_close_all_sessions();
	(void) object_mgr_purge_token_objects(hContext);

	(void) Tspi_Context_Close(hContext);

	(void) detach_shm();

	rc = pthread_mutex_unlock(&pkcs_mutex);
	if (rc != CKR_OK) {
		return (rc);
	}
	return (CKR_OK);
}
Beispiel #6
0
int buf_ctor(struct buf_s *buf, size_t bsiz, size_t rblk, size_t wblk, int rline, int wline, size_t hpage, size_t ioar, size_t ioaw)
{
	int ret = -1;
	size_t adj, page, idx, rblki, wblki, bsiza, csiza;

	if (!buf) {
		fputs("buf: no buf ?\n", stderr);
		return -1;
	}

	if (bsiz < 2*rblk || bsiz < 2*wblk) {
		fputs("buf: 'buffer size' must be at least 2*max('read block, 'write block'),\n"
		      "     to avoid corner case starvations.\n", stderr);
		return -1;
	}
	memset(buf, 0, sizeof *buf);

#ifndef h_mingw
	page = sysconf(_SC_PAGESIZE);
	if (page == hpage) {
		hpage = 0;
	}
	page = hpage ? hpage : page;
	adj = MAX(page, SHMLBA);
#else
	hpage = 0;
	adj = page = 4096;
#endif

	bsiza = ALIGN(bsiz, adj);
	if (!(idx = is_pow2(bsiza))) {
		fprintf(stderr, "buf: 'aligned buffer size' must be power of 2, but is: 0x%zX\n", bsiza);
		goto out;
	}
	buf->mask = (((size_t)1 << idx) - 1);
	rblki = ALIGN(rblk, ioar);
	wblki = ALIGN(wblk, ioaw);
	csiza = ALIGN(rblki + wblki, adj);
	buf->size = bsiza;

	preset_shm(buf);
	if (setup_shm(buf, bsiza, csiza, hpage) < 0) {
		fputs("buf: falling back to regular malloc()\n", stderr);
		ret = 1;
		detach_shm(buf);
		rm_shm(buf);
		preset_mal(buf);
		if (setup_mal(buf, bsiza, csiza, adj) < 0) {
			detach_mal(buf);
			ret = -1;
			goto out;
		}
	} else
		ret = 0;

	buf->rchunk = buf->chk;
	buf->wchunk = buf->chk + rblki;

	buf->flags |= hpage && buf->mapW ? M_HUGE : 0;
	buf->flags |= rline ? M_LINER : 0;
	buf->flags |= wline ? M_LINEW : 0;
//	buf->page = page;
	buf->ioar = ioar;
	buf->ioaw = ioaw;
	buf->rblk = rblk;
	buf->wblk = wblk;
	buf->crcw = crc_beg();
	buf->crcr = buf->crcw;
#if 0
	if (rblk < wblk && rline && !wline) {
		fputs("buf: 'read block' must be greater or equal to 'write block',\n"
		      "     if the left side is in the line mode,\n"
		      "     and the right side is in the reblocking mode.\n", stderr);
		goto out;
	}
#endif

	DEB("\nbuf map: C:%p, B:%p, B+S:%p, W:%p\n", buf->mapC, buf->mapB, buf->mapB + buf->size, buf->mapW);
	DEB("buf buf: C:%p, B:%p\n", buf->chk, buf->buf);
out:
	if (ret < 0)
		buf_dtor(buf);
	fputc('\n', stderr);
	return ret;
}