Beispiel #1
0
static unsigned char * handle_commit_quad (fs_backend *be, fs_segment segment,
                                             unsigned int length,
                                             unsigned char *content)
{
  if (segment > be->segments) {
    fs_error(LOG_ERR, "invalid segment number: %d", segment);
    return fsp_error_new(segment, "invalid segment number");
  }

  if (length != sizeof(int)) {
    fs_error(LOG_ERR, "commit_quad(%d) missing flags", segment);
    return fsp_error_new(segment, "missing flags");
  }

  int flags;

  memcpy(&flags, content, sizeof (flags));
  int ret = fs_quad_import_commit(be, segment, flags, 1);
  if (ret) {
    fs_error(LOG_ERR, "commit_quad(%d) failed", segment);
    return fsp_error_new(segment, "quad commit failed");
  }

  return message_new(FS_DONE_OK, segment, 0);
}
Beispiel #2
0
int fs_quad_import(fs_backend *be, int seg, int flags, int count, fs_rid buffer[][4])
{
    if ((flags & (FS_BIND_BY_SUBJECT | FS_BIND_BY_OBJECT)) == 0) {
	fs_error(LOG_ERR, "neither FS_BIND_BY_SUBJECT or FS_BIND_BY_OBJECT set");

	return 1;
    }
    if (flags & FS_BIND_BY_OBJECT) {
	fs_error(LOG_WARNING, "this backend doesn't use FS_BIND_BY_OBJECT");

	return 2;
    }

    if (seg < 0 || seg >= be->segments) {
	fs_error(LOG_ERR, "segment number %d out of range", seg);

	return 3;
    }

    double then = fs_time();
    int i = 0;
    while (i < count) {
	for (; i < count && quad_pos < QUAD_BUF_SIZE; i++, quad_pos++) {
	    quad_buffer[quad_pos].skip = 0;
	    quad_buffer[quad_pos].quad[0] = buffer[i][0];
	    quad_buffer[quad_pos].quad[1] = buffer[i][1];
	    quad_buffer[quad_pos].quad[2] = buffer[i][2];
	    quad_buffer[quad_pos].quad[3] = buffer[i][3];
	}
	if (quad_pos == QUAD_BUF_SIZE) {
	    if (!be->pended_import) {
		be->pended_import = 1;
		for (int pend=0; pend < FS_PENDED_LISTS; pend++) {
		    char label[256];
		    snprintf(label, 255, "pl-%1x", pend);
		    be->pended[pend] = fs_list_open(be, label,
			sizeof(fs_rid) * 4, O_CREAT | O_TRUNC | O_RDWR);
		}
	    }
	    int ret = fs_quad_import_commit(be, seg, flags, 0);
	    if (ret) {
		fs_error(LOG_CRIT, "quad commit failed");

		return ret;
	    }
	}
    }

    double now = fs_time();
    be->in_time[seg].add_s += now - then;

    return 0;
}