Ejemplo n.º 1
0
/*
 * BT_SYNC -- sync the btree to disk.
 *
 * Parameters:
 *	dbp:	pointer to access method
 *
 * Returns:
 *	RET_SUCCESS, RET_ERROR.
 */
int
__bt_sync(const DB *dbp, u_int flags)
{
	BTREE *t;
	int status;

	t = dbp->internal;

	/* Toss any page pinned across calls. */
	if (t->bt_pinned != NULL) {
		mpool_put(t->bt_mp, t->bt_pinned, 0);
		t->bt_pinned = NULL;
	}

	/* Sync doesn't currently take any flags. */
	if (flags != 0) {
		errno = EINVAL;
		return (RET_ERROR);
	}

	if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED))
		return (RET_SUCCESS);

	if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR)
		return (RET_ERROR);

	if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS)
		F_CLR(t, B_MODIFIED);

	return (status);
}
Ejemplo n.º 2
0
static void *thread_start(void *arg)
{
    struct thread_info *tinfo = (struct thread_info *) arg;

    struct timeval delay;
    delay.tv_sec = 30;
    delay.tv_usec = 0;//10000;//10ms
    while(!stop_daemon)
    {
        delay.tv_sec = 30;
        delay.tv_usec = 0;//10000;//10ms

        int rv = select(0,NULL,NULL,NULL,&delay);
        if(rv == 0)
        {
            pthread_mutex_lock(&mutex);
            mpool_sync(tinfo->mpool);
            pthread_mutex_unlock(&mutex);
        }
    }
    printf("Check Data Thread %d exit!\n",getpid());
    return NULL;
}